parent
8c04bd067c
commit
7b948f0380
@ -1,11 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
JsonController,
|
JsonController,
|
||||||
Param,
|
Param,
|
||||||
Body,
|
Body,
|
||||||
Get,
|
Get,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
Delete,
|
Delete,
|
||||||
} from "routing-controllers";
|
} from "routing-controllers";
|
||||||
import { OpenAPI } from "routing-controllers-openapi";
|
import { OpenAPI } from "routing-controllers-openapi";
|
||||||
import { getConnection, Repository } from "typeorm";
|
import { getConnection, Repository } from "typeorm";
|
||||||
@ -13,34 +13,32 @@ import { Track } from "../models/Track";
|
|||||||
|
|
||||||
@JsonController("/track")
|
@JsonController("/track")
|
||||||
export class TrackController {
|
export class TrackController {
|
||||||
private repo: Repository<Track>;
|
private repo(): Repository<Track> {
|
||||||
|
return getConnection().getRepository(Track);
|
||||||
|
}
|
||||||
|
|
||||||
public async TrackController() {
|
@Get("/track")
|
||||||
const trackManager = await getConnection().getRepository(Track);
|
async getAll() {
|
||||||
}
|
return await this.repo().find();
|
||||||
|
}
|
||||||
|
|
||||||
@Get("/track")
|
@Get("/track/:id")
|
||||||
async getAll() {
|
async getOne(@Param("id") id: number) {
|
||||||
return await this.repo.count();
|
return await this.repo().findOne({ id: id });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("/track/:id")
|
@Post("/track")
|
||||||
getOne(@Param("id") id: number) {
|
post(@Body() user: any) {
|
||||||
return "This action returns user #" + id;
|
return "Saving user...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post("/track")
|
@Put("/track/:id")
|
||||||
post(@Body() user: any) {
|
put(@Param("id") id: number, @Body() user: any) {
|
||||||
return "Saving user...";
|
return "Updating a user...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put("/track/:id")
|
@Delete("/track/:id")
|
||||||
put(@Param("id") id: number, @Body() user: any) {
|
remove(@Param("id") id: number) {
|
||||||
return "Updating a user...";
|
return "Removing user...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("/track/:id")
|
|
||||||
remove(@Param("id") id: number) {
|
|
||||||
return "Removing user...";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user