Compare commits

..

No commits in common. "796b8942d89ccd57fd8b5a9cd85fdc0b13f59c80" and "c85fddaa8e9dc60226db4ba45c33a2dc54465fca" have entirely different histories.

3 changed files with 8 additions and 34 deletions

View File

@ -25,7 +25,6 @@
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"class-transformer": "^0.3.1", "class-transformer": "^0.3.1",
"class-validator": "^0.12.2", "class-validator": "^0.12.2",
"class-validator-jsonschema": "^2.0.3",
"consola": "^2.15.0", "consola": "^2.15.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.17.1", "express": "^4.17.1",

View File

@ -2,23 +2,10 @@ import { Application } from "express";
import * as swaggerUiExpress from "swagger-ui-express"; import * as swaggerUiExpress from "swagger-ui-express";
import { getMetadataArgsStorage } from "routing-controllers"; import { getMetadataArgsStorage } from "routing-controllers";
import { routingControllersToSpec } from "routing-controllers-openapi"; import { routingControllersToSpec } from "routing-controllers-openapi";
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
export default async (app: Application) => { export default async (app: Application) => {
const storage = getMetadataArgsStorage(); const storage = getMetadataArgsStorage();
const schemas = validationMetadatasToSchemas({ const spec = routingControllersToSpec(storage);
refPointerPrefix: '#/components/schemas/',
});
const spec = routingControllersToSpec(storage, {}, {
components: {
schemas,
info: {
description: 'LfK! Backend API`',
title: 'LfK! Backend API',
version: '1.0.0'
}
});
app.use("/docs", swaggerUiExpress.serve, swaggerUiExpress.setup(spec)); app.use("/docs", swaggerUiExpress.serve, swaggerUiExpress.setup(spec));
return app; return app;
}; };

View File

@ -1,26 +1,14 @@
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"; import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
import {
IsInt,
IsNotEmpty,
IsOptional,
IsPositive,
IsString,
} from "class-validator";
@Entity() @Entity()
export class Track { export class Track {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
@IsOptional() id: number;
@IsInt()
id: number;
@Column() @Column()
@IsString() name: string;
@IsNotEmpty()
name: string;
@Column() //Length in meters
@IsInt() @Column()
@IsPositive() length: string;
length: string;
} }