version endpoint
This commit is contained in:
@@ -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ć <fjurma12@outlook.com>",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user