Some checks failed
Music Collection CI Workflow / test (./backend) (push) Failing after 26s
Music Collection CI Workflow / test (./frontend) (push) Successful in 38s
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
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
Post,
|
|
Put,
|
|
UsePipes,
|
|
ValidationPipe,
|
|
} from '@nestjs/common';
|
|
import { DeleteResult } from 'typeorm';
|
|
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[] | string | null> {
|
|
return this.songService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
findOneById(@Param('id') id: number): Promise<Song | string | null> {
|
|
return this.songService.findOneById(id);
|
|
}
|
|
|
|
@Post()
|
|
@UsePipes(new ValidationPipe({ transform: true }))
|
|
async create(
|
|
@Body() createSongDto: CreateSongDto,
|
|
): Promise<Song | string | null> {
|
|
return this.songService.create(createSongDto);
|
|
}
|
|
|
|
@Put(':id')
|
|
@UsePipes(new ValidationPipe({ transform: true }))
|
|
async update(
|
|
@Param('id') id: number,
|
|
@Body() updateSongDto: UpdateSongDto,
|
|
): Promise<Song | string | null> {
|
|
console.log(updateSongDto);
|
|
return this.songService.update(id, updateSongDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
async remove(@Param('id') id: number): Promise<DeleteResult | string | null> {
|
|
return this.songService.remove(id);
|
|
}
|
|
}
|