parent
da4597fa62
commit
6d81fc1309
@ -42,7 +42,7 @@ export class TrackController {
|
|||||||
@Body({ validate: true })
|
@Body({ validate: true })
|
||||||
track: CreateTrack
|
track: CreateTrack
|
||||||
) {
|
) {
|
||||||
return this.trackRepository.save(track.getTrack());
|
return this.trackRepository.save(track.toTrack());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('/:id')
|
@Put('/:id')
|
||||||
|
@ -2,15 +2,24 @@ import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
|
|||||||
import { Track } from './Track';
|
import { Track } from './Track';
|
||||||
|
|
||||||
export class CreateTrack {
|
export class CreateTrack {
|
||||||
|
/**
|
||||||
|
* The track's name.
|
||||||
|
*/
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The track's distance in meters (must be greater 0).
|
||||||
|
*/
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsPositive()
|
@IsPositive()
|
||||||
distance: number;
|
distance: number;
|
||||||
|
|
||||||
public getTrack(): Track {
|
/**
|
||||||
|
* Converts a Track object based on this.
|
||||||
|
*/
|
||||||
|
public toTrack(): Track {
|
||||||
let newTrack: Track = new Track();
|
let newTrack: Track = new Track();
|
||||||
|
|
||||||
newTrack.name = this.name;
|
newTrack.name = this.name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user