add getStatus and cases

This commit is contained in:
Michael C
2021-09-01 16:52:41 -04:00
parent d6a986d6cf
commit e12724af15
6 changed files with 58 additions and 1 deletions

18
src/routes/getStatus.ts Normal file
View File

@@ -0,0 +1,18 @@
import {db} from "../databases/databases";
import {Logger} from "../utils/logger";
import {Request, Response} from "express";
export async function getStatus(req: Request, res: Response): Promise<Response> {
try {
const dbVersion = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
return res.send({
uptime: process.uptime(),
commit: (global as any).HEADCOMMIT || "unknown",
db: Number(dbVersion),
});
} catch (err) {
Logger.error(err as string);
return res.sendStatus(500);
}
}