From 224c2f32c7ebc42fcbaebfe36bcc07198abc9eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Jurmanovi=C4=87?= Date: Mon, 2 Oct 2023 21:34:48 +0200 Subject: [PATCH] version endpoint --- package.json | 8 +++----- src/controllers/Client.controller.ts | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index de1a86e..08e62eb 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,9 @@ { - "name": "scheduled", - "version": "0.0.1", + "name": "legica-dana", + "version": "0.7.0", "main": "src/app.ts", "scripts": { - "start": "bun src/app.ts", - "dev": "nodemon app.ts", - "build": "tsc --build" + "start": "bun src/app.ts" }, "author": "Fran Jurmanović ", "license": "MIT", diff --git a/src/controllers/Client.controller.ts b/src/controllers/Client.controller.ts index 8147dca..f6eb70d 100644 --- a/src/controllers/Client.controller.ts +++ b/src/controllers/Client.controller.ts @@ -4,7 +4,7 @@ import axios from "axios"; import cheerio from "cheerio"; import { Express } from "express"; import { IController, Legica } from "@models"; -import { config } from "@constants"; +import { APP_VERSION, config } from "@constants"; class ClientController implements IController { private legicaTask: cron.CronJob | null = null; @@ -25,6 +25,18 @@ class ClientController implements IController { res.send(this.legicaTask?.running); }); + this.app.get("/next", (_, res) => { + if (!this.legicaTask?.running) { + res.status(400).send("Task is not running."); + } else { + res.send(this.legicaTask.nextDate().toISO()); + } + }); + + this.app.get("/version", (_, res) => { + res.send(APP_VERSION); + }); + this.app.post("/start", (_, res) => { if (this.legicaTask?.running) { res.status(400).send("Task already running."); @@ -43,14 +55,6 @@ class ClientController implements IController { } }); - this.app.get("/next", (_, res) => { - if (!this.legicaTask?.running) { - res.status(400).send("Task is not running."); - } else { - res.send(this.legicaTask.nextDate().toISO()); - } - }); - this.app.post("/post-next", async (_, res) => { try { await this.sendNextMessage();