music-collection/backend/src/song/song.controller.ts
Phill Pover 4f389f70af
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 29s
Music Collection CI Workflow / test (./frontend) (push) Successful in 36s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Successful in 51s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Failing after 1m29s
Music Collection CI Workflow / deploy (push) Has been skipped
Fixing tests
2025-04-07 04:05:42 +01:00

40 lines
1.2 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[]> {
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<Song | null> {
return this.songService.create(createSongDto);
}
@Put(':id')
@UsePipes(new ValidationPipe({ transform: true }))
async update(@Param('id') id: number, @Body() updateSongDto: UpdateSongDto): Promise<Song | null> {
return this.songService.update(id, updateSongDto);
}
@Delete(':id')
async remove(@Param('id') id: number): Promise<DeleteResult> {
return this.songService.remove(id);
}
}