Some checks failed
Music Collection CI Workflow / test (./backend) (push) Failing after 37s
Music Collection CI Workflow / test (./frontend) (push) Successful in 34s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been skipped
Music Collection CI Workflow / deploy (push) Has been skipped
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Put, UsePipes, ValidationPipe } from '@nestjs/common';
|
|
import { SongService } from './song.service';
|
|
import { Song } from './song.entity';
|
|
import { CreateSongDto } from './dto/create-song.dto';
|
|
import { UpdateSongDto } from './dto/update-song.dto';
|
|
|
|
@Controller('song')
|
|
export class SongController {
|
|
|
|
constructor(private readonly songService: SongService) {}
|
|
|
|
@Get()
|
|
findAll(): Promise<Song[]> {
|
|
return this.songService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
findOneById(@Param('id') id: number): Promise<Song | null> {
|
|
return this.songService.findOneById(id);
|
|
}
|
|
|
|
@Post()
|
|
@UsePipes(new ValidationPipe({ transform: true }))
|
|
async create(@Body() createSongDto: CreateSongDto): Promise<number> {
|
|
return this.songService.create(createSongDto);
|
|
}
|
|
|
|
@Put(':id')
|
|
@UsePipes(new ValidationPipe({ transform: true }))
|
|
async update(@Param('id') id: number, @Body() updateSongDto: UpdateSongDto): Promise<string> {
|
|
return this.songService.update(id, updateSongDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
async remove(@Param('id') id: number): Promise<void> {
|
|
return this.songService.remove(id);
|
|
}
|
|
}
|