async checkUserMemberOfProduct(userId: string, productId: string) {
if (userId && productId) {
const user = await Product.find({ where: { userId: userId, id: productId } });
return !!user;
}
return false;
}
I want to create this function as decorator. And call it above endpoint. For example
@checkUserMemberOfProduct()
@post('/roles')
async create(
@requestBody() user: User
): Promise<Role> {
return this.roleRepository.create(role);
}
But I am not sure how to pass request body to this decorator. Is it possible to use this fn as decorator?