parent
860b6c850d
commit
e5562efe35
|
@ -8,12 +8,20 @@ import {
|
|||
Delete,
|
||||
} from "routing-controllers";
|
||||
import { getConnectionManager, Repository } from "typeorm";
|
||||
import {
|
||||
EntityFromParam,
|
||||
EntityFromBody,
|
||||
} from "typeorm-routing-controllers-extensions";
|
||||
import { EntityFromBody } from "typeorm-routing-controllers-extensions";
|
||||
import { ResponseSchema } from "routing-controllers-openapi";
|
||||
import { Track } from "../models/Track";
|
||||
import { IsInt, IsNotEmpty, IsPositive, IsString } from "class-validator";
|
||||
|
||||
class CreateTrack {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
name: string;
|
||||
|
||||
@IsInt()
|
||||
@IsPositive()
|
||||
length: string;
|
||||
}
|
||||
|
||||
@JsonController("/track")
|
||||
export class TrackController {
|
||||
|
@ -36,7 +44,7 @@ export class TrackController {
|
|||
}
|
||||
|
||||
@Post()
|
||||
post(@EntityFromBody() track: Track) {
|
||||
post(@Body({ validate: true }) track: CreateTrack) {
|
||||
return this.trackRepository.save(track);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue