uptime monitor endpoint
This commit is contained in:
@ -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
0
src/service/index.ts
Normal file
19
src/service/uptime.ts
Normal file
19
src/service/uptime.ts
Normal 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
3
src/tools/startupTime.ts
Normal file
@ -0,0 +1,3 @@
|
||||
const startupTime = new Date();
|
||||
|
||||
export default startupTime;
|
Reference in New Issue
Block a user