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.
This commit is contained in:
2026-03-07 12:05:27 -08:00
committed by Naomi Carrigan
parent 29f92fff88
commit 01146a4999
+1 -7
View File
@@ -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";