version endpoint
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "scheduled",
|
"name": "legica-dana",
|
||||||
"version": "0.0.1",
|
"version": "0.7.0",
|
||||||
"main": "src/app.ts",
|
"main": "src/app.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "bun src/app.ts",
|
"start": "bun src/app.ts"
|
||||||
"dev": "nodemon app.ts",
|
|
||||||
"build": "tsc --build"
|
|
||||||
},
|
},
|
||||||
"author": "Fran Jurmanović <fjurma12@outlook.com>",
|
"author": "Fran Jurmanović <fjurma12@outlook.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import axios from "axios";
|
|||||||
import cheerio from "cheerio";
|
import cheerio from "cheerio";
|
||||||
import { Express } from "express";
|
import { Express } from "express";
|
||||||
import { IController, Legica } from "@models";
|
import { IController, Legica } from "@models";
|
||||||
import { config } from "@constants";
|
import { APP_VERSION, config } from "@constants";
|
||||||
|
|
||||||
class ClientController implements IController {
|
class ClientController implements IController {
|
||||||
private legicaTask: cron.CronJob | null = null;
|
private legicaTask: cron.CronJob | null = null;
|
||||||
@@ -25,6 +25,18 @@ class ClientController implements IController {
|
|||||||
res.send(this.legicaTask?.running);
|
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) => {
|
this.app.post("/start", (_, res) => {
|
||||||
if (this.legicaTask?.running) {
|
if (this.legicaTask?.running) {
|
||||||
res.status(400).send("Task already 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) => {
|
this.app.post("/post-next", async (_, res) => {
|
||||||
try {
|
try {
|
||||||
await this.sendNextMessage();
|
await this.sendNextMessage();
|
||||||
|
|||||||
Reference in New Issue
Block a user