42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { Body, Controller, Delete, Get, HttpCode, Param, ParseIntPipe, Post, Patch } from '@nestjs/common';
|
|
import { RecipesService } from './recipes.service';
|
|
import { CreateRecipeDto } from './dto/create-recipe.dto';
|
|
|
|
@Controller('recipes')
|
|
export class RecipesController {
|
|
constructor(private readonly recipesService: RecipesService) {}
|
|
|
|
@Get()
|
|
findAll() {
|
|
return this.recipesService.findAll();
|
|
}
|
|
|
|
@Get(':id/inventory-preview')
|
|
getInventoryPreview(@Param('id', ParseIntPipe) id: number) {
|
|
return this.recipesService.getInventoryPreview(id);
|
|
}
|
|
|
|
@Get(':id')
|
|
findOne(@Param('id', ParseIntPipe) id: number) {
|
|
return this.recipesService.findOne(id);
|
|
}
|
|
|
|
@Post()
|
|
async create(@Body() createRecipeDto: CreateRecipeDto) {
|
|
return this.recipesService.create(createRecipeDto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
async update(
|
|
@Param('id', ParseIntPipe) id: number,
|
|
@Body() createRecipeDto: CreateRecipeDto,
|
|
) {
|
|
return this.recipesService.update(id, createRecipeDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@HttpCode(204)
|
|
async remove(@Param('id', ParseIntPipe) id: number) {
|
|
return this.recipesService.remove(id);
|
|
}
|
|
} |