feat: add /v endpoint for identifying api repo vesion

This commit is contained in:
Ritesh Ghosh
2024-12-22 00:39:13 +05:30
parent 75dcf6bfeb
commit 062e662fbc
+6
View File
@@ -13,6 +13,7 @@ import { serveStatic } from "@hono/node-server/serve-static";
import { HiAnimeError } from "aniwatch"; import { HiAnimeError } from "aniwatch";
import { AniwatchAPICache } from "./config/cache.js"; import { AniwatchAPICache } from "./config/cache.js";
import pkgJson from "../package.json" with { type: "json" };
import type { AniwatchAPIVariables } from "./config/variables.js"; import type { AniwatchAPIVariables } from "./config/variables.js";
config(); config();
@@ -36,6 +37,11 @@ if (ISNT_PERSONAL_DEPLOYMENT) {
app.use("/", serveStatic({ root: "public" })); app.use("/", serveStatic({ root: "public" }));
app.get("/health", (c) => c.text("OK", { status: 200 })); app.get("/health", (c) => c.text("OK", { status: 200 }));
app.get("/v", async (c) =>
c.text(
`v${"version" in pkgJson && pkgJson?.version ? pkgJson.version : "-1"}`
)
);
app.use(async (c, next) => { app.use(async (c, next) => {
const { pathname, search } = new URL(c.req.url); const { pathname, search } = new URL(c.req.url);