From 65edb82c1072ad8f3f1071c8239dc7fc118adbd6 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Thu, 22 Jan 2026 16:07:50 +0100 Subject: [PATCH] fix: import package.json at build time --- Dockerfile | 1 + src/server.ts | 11 +++++------ tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2224cc7..192059d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ COPY bunfig.toml bunfig.toml COPY package.json package.json COPY test-setup.ts test-setup.ts COPY tsconfig.json tsconfig.json +COPY package.json package.json # tests & build ENV NODE_ENV=production diff --git a/src/server.ts b/src/server.ts index f233d0a..2506c9c 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,6 +1,7 @@ import { cors } from '@elysiajs/cors'; import { openapi } from '@elysiajs/openapi'; import { Elysia } from 'elysia'; +import packageJson from '../package.json'; import { GitHubDecorator } from './decorators/github'; import { JwtDecorator } from './decorators/jwt'; import { GitHubApiError, GitHubAuthUnauthorizedError, NullishError } from './errors'; @@ -12,11 +13,7 @@ import { } from './handlers/auth/github'; import { authJwks } from './handlers/auth/jwks'; -const { - version: appVersion, - name: appName, - description: appDescription -} = await Bun.file('./package.json').json(); +const { version: appVersion, name: appName, description: appDescription } = packageJson; export const app = new Elysia() .error({ @@ -64,4 +61,6 @@ export const app = new Elysia() ) .listen(3000); -console.log(`🛰️ Juno API is running at ${app.server?.hostname}:${app.server?.port}`); +console.log( + `🛰️ Juno API (v${appVersion}) is running at ${app.server?.hostname}:${app.server?.port}` +); diff --git a/tsconfig.json b/tsconfig.json index eb284dc..fc726e7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,7 +37,7 @@ ] /* Specify type package names to be included without being referenced in a source file. */, // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ + "resolveJsonModule": true /* Enable importing .json files. */, // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ /* JavaScript Support */