parent
e29d59ac02
commit
c15b650181
@ -6,6 +6,7 @@ import {
|
|||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
Delete,
|
Delete,
|
||||||
|
Authorized,
|
||||||
} from "routing-controllers";
|
} from "routing-controllers";
|
||||||
import { getConnectionManager, Repository } from "typeorm";
|
import { getConnectionManager, Repository } from "typeorm";
|
||||||
import { EntityFromBody } from "typeorm-routing-controllers-extensions";
|
import { EntityFromBody } from "typeorm-routing-controllers-extensions";
|
||||||
@ -24,6 +25,7 @@ class CreateTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonController("/track")
|
@JsonController("/track")
|
||||||
|
@Authorized("TRACKS:read")
|
||||||
export class TrackController {
|
export class TrackController {
|
||||||
private trackRepository: Repository<Track>;
|
private trackRepository: Repository<Track>;
|
||||||
|
|
||||||
@ -43,11 +45,13 @@ export class TrackController {
|
|||||||
return this.trackRepository.findOne({ id: id });
|
return this.trackRepository.findOne({ id: id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Authorized("TRACKS:write")
|
||||||
@Post()
|
@Post()
|
||||||
post(@Body({ validate: true }) track: CreateTrack) {
|
post(@Body({ validate: true }) track: CreateTrack) {
|
||||||
return this.trackRepository.save(track);
|
return this.trackRepository.save(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Authorized("TRACKS:write")
|
||||||
@Put("/:id")
|
@Put("/:id")
|
||||||
put(@Param("id") id: number, @EntityFromBody() track: Track) {
|
put(@Param("id") id: number, @EntityFromBody() track: Track) {
|
||||||
return this.trackRepository.update({ id: id }, track);
|
return this.trackRepository.update({ id: id }, track);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user