-
-
Save imflamboyant/ac07806b69d0b92258601e47cf3d7ce1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post } from '@nestjs/common'; | |
| import { SongService } from './song.service'; | |
| import { Song } from './entities/song.entity'; | |
| @Controller('songs') | |
| export class SongController { | |
| constructor(private readonly songService: SongService) { | |
| } | |
| @Post() | |
| async create(@Body() song: Song): Promise<Song> { | |
| return await this.songService.create(song); | |
| } | |
| @Get() | |
| async findAll(): Promise<Song[]> { | |
| return await this.songService.findAll(); | |
| } | |
| @Get(':id') | |
| async findOne(@Param('id', ParseIntPipe) id: number): Promise<Song> { | |
| return await this.songService.findOne(id); | |
| } | |
| @Delete(':id') | |
| async remove(@Param('id', ParseIntPipe) id: number): Promise<void> { | |
| await this.songService.remove(id); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment