From 062e662fbcde1947694b39740b9896f75325959c Mon Sep 17 00:00:00 2001 From: Ritesh Ghosh Date: Sun, 22 Dec 2024 00:39:13 +0530 Subject: [PATCH] feat: add `/v` endpoint for identifying api repo vesion --- src/server.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/server.ts b/src/server.ts index 1b69c39..41a64c5 100644 --- a/src/server.ts +++ b/src/server.ts @@ -13,6 +13,7 @@ import { serveStatic } from "@hono/node-server/serve-static"; import { HiAnimeError } from "aniwatch"; import { AniwatchAPICache } from "./config/cache.js"; +import pkgJson from "../package.json" with { type: "json" }; import type { AniwatchAPIVariables } from "./config/variables.js"; config(); @@ -36,6 +37,11 @@ if (ISNT_PERSONAL_DEPLOYMENT) { app.use("/", serveStatic({ root: "public" })); 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) => { const { pathname, search } = new URL(c.req.url);