From 01146a4999773c4a477561b265fec0835eb9c0f2 Mon Sep 17 00:00:00 2001 From: Hikari Date: Sat, 7 Mar 2026 12:05:27 -0800 Subject: [PATCH] refactor: use npm_package_version env var for API version Replaces the readFileSync/path gymnastics with the simpler npm_package_version environment variable that npm injects at runtime. --- apps/api/src/routes/about.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/api/src/routes/about.ts b/apps/api/src/routes/about.ts index 865048d..be9d626 100644 --- a/apps/api/src/routes/about.ts +++ b/apps/api/src/routes/about.ts @@ -1,13 +1,7 @@ -import { readFileSync } from "node:fs"; -import { dirname, join } from "node:path"; -import { fileURLToPath } from "node:url"; import { Hono } from "hono"; import type { AboutResponse, GiteaRelease } from "@elysium/types"; -const __dirname = dirname(fileURLToPath(import.meta.url)); -const { version: API_VERSION } = JSON.parse( - readFileSync(join(__dirname, "../../../package.json"), "utf-8"), -) as { version: string }; +const API_VERSION = process.env.npm_package_version ?? "unknown"; const GITEA_RELEASES_URL = "https://git.nhcarrigan.com/api/v1/repos/nhcarrigan-ideation/elysium/releases";