backend/src/controllers/StatusController.ts
Nicolai Ort a2f4fd5d9b
All checks were successful
continuous-integration/drone/pr Build is passing
Introduces a very basic version getting endpoint
ref #91
2021-01-12 17:41:42 +01:00

31 lines
958 B
TypeScript

import { Get, JsonController } from 'routing-controllers';
import { OpenAPI } from 'routing-controllers-openapi';
import { getConnection } from 'typeorm';
import { config } from '../config';
@JsonController()
export class StatusController {
@Get('/status')
@OpenAPI({ description: "A very basic status/health endpoint that just checks if the database connection is available. <br> The available information depth will be expanded later." })
get() {
let connection;
try {
connection = getConnection();
} catch {
throw new Error("sth is wrong, i can feel it....");
}
return {
"controllers": "✔",
"database connection": "✔"
};
}
@Get('/version')
@OpenAPI({ description: "A very basic endpoint that just returns the curent package version." })
getVersion() {
return {
"version": config.version
}
}
}