Compare commits

...

3 Commits

View File

@ -8,17 +8,23 @@ import {
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 { Track } from "../models/Track";
@JsonController() @JsonController("/track")
export class TrackController { export class TrackController {
private repo(): Repository<Track> {
return getConnection().getRepository(Track);
}
@Get("/track") @Get("/track")
getAll() { async getAll() {
return "This action returns all users"; return await this.repo().find();
} }
@Get("/track/:id") @Get("/track/:id")
getOne(@Param("id") id: number) { async getOne(@Param("id") id: number) {
return "This action returns user #" + id; return await this.repo().findOne({ id: id });
} }
@Post("/track") @Post("/track")