async verifyUserMembership(userId: string, productId: string) {
if (userId && productId) {
const userExists = await Product.find({ where: { userId: userId, id: productId } });
return !!userExists;
}
return false;
}
I am interested in turning this function into a decorator and applying it to the above endpoint. Here is an example:
@verifyUserMembership()
@post('/roles')
async create(
@requestBody() newUser: User
): Promise<Role> {
return this.roleRepository.create(role);
}
I'm unsure how to pass the request body to this decorator. Can this function be used as a decorator?