9router / src /lib /db /version.js
2api
feat: configurable stream stall timeout + per-provider UI
88c4c60
Raw
History Blame Contribute Delete
669 Bytes
import fs from "node:fs";
import path from "node:path";
let cachedVersion = null;
export function getAppVersion() {
if (cachedVersion) return cachedVersion;
try {
const pkgPath = path.join(process.cwd(), "package.json");
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
cachedVersion = pkg.version || "0.0.0";
} catch {
cachedVersion = "0.0.0";
}
return cachedVersion;
}
export function timestampSlug(date = new Date()) {
const pad = (n) => String(n).padStart(2, "0");
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}-${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`;
}