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