uptime monitor endpoint

This commit is contained in:
2022-11-24 22:58:27 +01:00
parent 7be72df267
commit f7727c3542
7 changed files with 674 additions and 4 deletions

View File

@ -3,13 +3,13 @@ import { stdin as input, stdout as output } from "node:process";
import pack from "../../package.json";
import { Console } from "node:console";
import moment from "moment";
import startupTime from "../tools/startupTime";
import guild from "./guild";
import global from "./global";
const console = new Console(process.stdout);
const startupTime = new Date();
const rl = readline.createInterface(input, output);
rl.on("line", async (msg) => {

0
src/service/index.ts Normal file
View File

19
src/service/uptime.ts Normal file
View File

@ -0,0 +1,19 @@
import express from "express";
import pack from "../../package.json";
import startupTime from "../tools/startupTime";
const app = express();
app.get("/", (_req, res) => {
res.status(200).json({
running: true,
version: pack.version,
runningSince: startupTime.toISOString()
});
});
app.all("*", (_req, res) => {
res.status(404).end();
});
app.listen(80);

3
src/tools/startupTime.ts Normal file
View File

@ -0,0 +1,3 @@
const startupTime = new Date();
export default startupTime;