latest work #20

Merged
philipp merged 233 commits from dev into main 2020-12-09 18:49:33 +00:00
Showing only changes of commit 0e3cf07b91 - Show all commits

View File

@ -1,7 +1,7 @@
import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions';
import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors";
import { CreateTrack } from '../models/creation/CreateTrack';
import { Track } from '../models/entities/Track';
@ -74,12 +74,8 @@ export class TrackController {
@ResponseSchema(ResponseTrack)
@ResponseSchema(TrackNotFoundError, { statusCode: 404 })
@OpenAPI({ description: "Delete a specified track (if it exists)." })
async remove(@Param('id') id: number) {
let track = await this.trackRepository.findOne({ id: id });
if (!track) {
throw new TrackNotFoundError();
}
async remove(@EntityFromParam('id') track: Track) {
if (!track) { throw new TrackNotFoundError(); }
await this.trackRepository.delete(track);
return new ResponseTrack(track);