Skip to content

Instantly share code, notes, and snippets.

@imflamboyant
Created May 4, 2022 08:49
Show Gist options
  • Select an option

  • Save imflamboyant/ac07806b69d0b92258601e47cf3d7ce1 to your computer and use it in GitHub Desktop.

Select an option

Save imflamboyant/ac07806b69d0b92258601e47cf3d7ce1 to your computer and use it in GitHub Desktop.
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