list of favorites

This commit is contained in:
2025-12-22 14:15:48 +03:30
parent 2030132ea5
commit 2a6d53b04d
2 changed files with 12 additions and 0 deletions
@@ -56,6 +56,14 @@ export class FoodController {
return this.foodsService.toggleFavorite(userId, foodId);
}
@Get('public/foods/favorite')
@UseGuards(AuthGuard)
@ApiHeader(API_HEADER_SLUG)
@ApiBearerAuth()
@ApiOperation({ summary: 'get my favorites' })
getMyFavorites(@UserId() userId: string) {
return this.foodsService.getMyFavorites(userId);
}
/* ---------------------------------- Admin ---------------------------------- */
@UseGuards(AdminAuthGuard)
@@ -260,6 +260,10 @@ export class FoodService {
return this.em.persistAndFlush(newFavorite);
}
async getMyFavorites(userId: string) {
return this.em.find(Favorite, { user: userId }, { populate: ['food'] });
}
/**
* Invalidate cache for restaurant foods
*/