Switched to using a response model for tracks
This commit is contained in:
35
src/models/responses/ResponseTrack.ts
Normal file
35
src/models/responses/ResponseTrack.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user