feat(app): stats added in to check if build in last build and also if theres a pending file

This commit is contained in:
2025-09-26 10:44:41 -05:00
parent 86dea6083e
commit 58aedecd4d
25 changed files with 2113 additions and 42 deletions

View File

@@ -0,0 +1,34 @@
import { Router } from "express";
import { tryCatch } from "../../../pkg/utils/tryCatch.js";
import { db } from "../../../pkg/db/db.js";
import {
serverStats,
type ServerStats,
} from "../../../pkg/db/schema/serverstats.js";
import { eq } from "drizzle-orm";
import { format } from "date-fns-tz";
import { checkBuildUpdate } from "../utlis/checkForBuild.js";
const router = Router();
// GET /health
router.get("/", async (req, res) => {
const { data, error } = await tryCatch(
db.select().from(serverStats).where(eq(serverStats.id, "serverStats"))
);
if (error || !data) {
res.status(400).json({ error: error });
}
const statData = data as ServerStats[];
res.json({
status: "ok",
uptime: process.uptime(),
build: statData[0]?.build,
pendingUpdateFile: await checkBuildUpdate(["."]),
lastUpdate: format(statData[0].lastUpdate!, "MM/dd/yyyy HH:mm"),
});
});
export default router;