feat: make pantry items and meal plan entries user-scoped; update related services and controllers
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user