Deletes now return 204 instead of 404 (better rest compatability)
ref #13
This commit is contained in:
@@ -5,6 +5,7 @@ import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-ext
|
||||
import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors";
|
||||
import { CreateTrack } from '../models/actions/CreateTrack';
|
||||
import { Track } from '../models/entities/Track';
|
||||
import { ResponseEmpty } from '../models/responses/ResponseEmpty';
|
||||
import { ResponseTrack } from '../models/responses/ResponseTrack';
|
||||
|
||||
@JsonController('/tracks')
|
||||
@@ -74,10 +75,11 @@ export class TrackController {
|
||||
|
||||
@Delete('/:id')
|
||||
@ResponseSchema(ResponseTrack)
|
||||
@ResponseSchema(TrackNotFoundError, { statusCode: 404 })
|
||||
@ResponseSchema(ResponseEmpty, { statusCode: 204 })
|
||||
@OnUndefined(204)
|
||||
@OpenAPI({ description: "Delete a specified track (if it exists)." })
|
||||
async remove(@EntityFromParam('id') track: Track) {
|
||||
if (!track) { throw new TrackNotFoundError(); }
|
||||
if (!track) { return null; }
|
||||
|
||||
await this.trackRepository.delete(track);
|
||||
return new ResponseTrack(track);
|
||||
|
||||
Reference in New Issue
Block a user