| @@ -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,14 +74,10 @@ 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); | ||||
| 	} | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user