feat: make pantry items and meal plan entries user-scoped; update related services and controllers

This commit is contained in:
Nils-Johan Gynther
2026-04-22 18:38:04 +02:00
parent 44b4e7ad73
commit 4482129fca
6 changed files with 123 additions and 35 deletions
+13 -6
View File
@@ -1,23 +1,30 @@
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post } from '@nestjs/common';
import { PantryService } from './pantry.service';
import { CreatePantryItemDto } from './dto/create-pantry-item.dto';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
@Controller('pantry')
export class PantryController {
constructor(private readonly pantryService: PantryService) {}
@Get()
findAll() {
return this.pantryService.findAll();
findAll(@CurrentUser() user: { userId: number }) {
return this.pantryService.findAll(user.userId);
}
@Post()
create(@Body() body: CreatePantryItemDto) {
return this.pantryService.create(body);
create(
@CurrentUser() user: { userId: number },
@Body() body: CreatePantryItemDto,
) {
return this.pantryService.create(user.userId, body);
}
@Delete(':id')
remove(@Param('id', ParseIntPipe) id: number) {
return this.pantryService.remove(id);
remove(
@CurrentUser() user: { userId: number },
@Param('id', ParseIntPipe) id: number,
) {
return this.pantryService.remove(user.userId, id);
}
}