| @@ -23,6 +23,7 @@ export class TrackController { | ||||
| 	@Get() | ||||
| 	@Authorized("TRACK:GET") | ||||
| 	@ResponseSchema(ResponseTrack, { isArray: true }) | ||||
| 	@OpenAPI({ description: 'Lists all tracks.' }) | ||||
| 	async getAll() { | ||||
| 		let responseTracks: ResponseTrack[] = new Array<ResponseTrack>(); | ||||
| 		const tracks = await this.trackRepository.find(); | ||||
| @@ -37,7 +38,7 @@ export class TrackController { | ||||
| 	@ResponseSchema(ResponseTrack) | ||||
| 	@ResponseSchema(TrackNotFoundError, { statusCode: 404 }) | ||||
| 	@OnUndefined(TrackNotFoundError) | ||||
| 	@OpenAPI({ description: "Returns a track of a specified id (if it exists)" }) | ||||
| 	@OpenAPI({ description: "Lists all information about the track whose id got provided." }) | ||||
| 	async getOne(@Param('id') id: number) { | ||||
| 		let track = await this.trackRepository.findOne({ id: id }); | ||||
| 		if (!track) { throw new TrackNotFoundError(); } | ||||
| @@ -47,7 +48,7 @@ export class TrackController { | ||||
| 	@Post() | ||||
| 	@Authorized("TRACK:CREATE") | ||||
| 	@ResponseSchema(ResponseTrack) | ||||
| 	@OpenAPI({ description: "Create a new track object (id will be generated automagicly)." }) | ||||
| 	@OpenAPI({ description: "Create a new track. <br> Please remember that the track\'s distance must be greater than 0." }) | ||||
| 	async post( | ||||
| 		@Body({ validate: true }) | ||||
| 		track: CreateTrack | ||||
| @@ -60,7 +61,7 @@ export class TrackController { | ||||
| 	@ResponseSchema(ResponseTrack) | ||||
| 	@ResponseSchema(TrackNotFoundError, { statusCode: 404 }) | ||||
| 	@ResponseSchema(TrackIdsNotMatchingError, { statusCode: 406 }) | ||||
| 	@OpenAPI({ description: "Update a track object (id can't be changed)." }) | ||||
| 	@OpenAPI({ description: "Update the track whose id you provided. <br> Please remember that id's can't be changed." }) | ||||
| 	async put(@Param('id') id: number, @EntityFromBody() track: Track) { | ||||
| 		let oldTrack = await this.trackRepository.findOne({ id: id }); | ||||
|  | ||||
| @@ -81,7 +82,7 @@ export class TrackController { | ||||
| 	@ResponseSchema(ResponseTrack) | ||||
| 	@ResponseSchema(ResponseEmpty, { statusCode: 204 }) | ||||
| 	@OnUndefined(204) | ||||
| 	@OpenAPI({ description: "Delete a specified track (if it exists)." }) | ||||
| 	@OpenAPI({ description: "Delete the track whose id you provided. <br> If no track with this id exists it will just return 204(no content)." }) | ||||
| 	async remove(@Param("id") id: number) { | ||||
| 		let track = await this.trackRepository.findOne({ id: id }); | ||||
| 		if (!track) { return null; } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user