From cea5993049b3c7098c33a2191db496656d72589e Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Fri, 18 Dec 2020 22:58:24 +0100 Subject: [PATCH 1/2] 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 -- 2.47.2 From a0a08f7724e64c05e3a6bec74071d2a0f74b8f7e Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Fri, 18 Dec 2020 23:00:27 +0100 Subject: [PATCH 2/2] Formatting implemented for @philipp ref #34 --- src/controllers/StatusController.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/controllers/StatusController.ts b/src/controllers/StatusController.ts index 08bf150..9f83c50 100644 --- a/src/controllers/StatusController.ts +++ b/src/controllers/StatusController.ts @@ -11,13 +11,12 @@ export class StatusController { let connection; try { connection = getConnection(); - } - catch { - throw new Error("sth is wrong, i can feel it....") + } catch { + throw new Error("sth is wrong, i can feel it...."); } return { "controllers": "✔", "database connection": "✔" - } + }; } } \ No newline at end of file -- 2.47.2