From cea5993049b3c7098c33a2191db496656d72589e Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Fri, 18 Dec 2020 22:58:24 +0100 Subject: [PATCH] added a simple health route ref #34 --- src/controllers/StatusController.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/controllers/StatusController.ts diff --git a/src/controllers/StatusController.ts b/src/controllers/StatusController.ts new file mode 100644 index 0000000..08bf150 --- /dev/null +++ b/src/controllers/StatusController.ts @@ -0,0 +1,23 @@ +import { Get, JsonController } from 'routing-controllers'; +import { OpenAPI } from 'routing-controllers-openapi'; +import { getConnection } from 'typeorm'; + +@JsonController('/status') +export class StatusController { + + @Get() + @OpenAPI({ description: "Lists all tracks." }) + get() { + let connection; + try { + connection = getConnection(); + } + catch { + throw new Error("sth is wrong, i can feel it....") + } + return { + "controllers": "✔", + "database connection": "✔" + } + } +} \ No newline at end of file