Switched to using a response model for tracks

This commit is contained in:
2020-12-04 18:34:01 +01:00
parent 65f995cb9f
commit 913033373b
2 changed files with 57 additions and 17 deletions

View File

@@ -0,0 +1,35 @@
import {
IsInt,
IsString
} from "class-validator";
import { Track } from '../entities/Track';
/**
* Defines a track of given length.
*/
export class ResponseTrack {
/**
* Autogenerated unique id (primary key).
*/
@IsInt()
id: number;;
/**
* The track's name.
*/
@IsString()
name: string;
/**
* The track's length/distance in meters.
*/
@IsInt()
distance: number;
public constructor(track: Track) {
this.id = track.id;
this.name = track.name;
this.distance = track.distance;
}
}