Fix for getting one

ref #13
This commit is contained in:
2020-12-09 18:11:23 +01:00
parent e4cb8eba1d
commit 204e2352a9
4 changed files with 12 additions and 4 deletions

View File

@@ -37,7 +37,9 @@ export class TrackController {
@OnUndefined(TrackNotFoundError)
@OpenAPI({ description: "Returns a track of a specified id (if it exists)" })
async getOne(@Param('id') id: number) {
return new ResponseTrack(await this.trackRepository.findOne({ id: id }));
let track = await this.trackRepository.findOne({ id: id });
if (!track) { throw new TrackNotFoundError(); }
return new ResponseTrack(track);
}
@Post()