Skip to content

Commit 9ddc486

Browse files
fix: import package.json at build time (#2)
1 parent 693f992 commit 9ddc486

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ COPY bunfig.toml bunfig.toml
2828
COPY package.json package.json
2929
COPY test-setup.ts test-setup.ts
3030
COPY tsconfig.json tsconfig.json
31+
COPY package.json package.json
3132

3233
# tests & build
3334
ENV NODE_ENV=production

src/server.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { cors } from '@elysiajs/cors';
22
import { openapi } from '@elysiajs/openapi';
33
import { Elysia } from 'elysia';
4+
import packageJson from '../package.json';
45
import { GitHubDecorator } from './decorators/github';
56
import { JwtDecorator } from './decorators/jwt';
67
import { GitHubApiError, GitHubAuthUnauthorizedError, NullishError } from './errors';
@@ -12,11 +13,7 @@ import {
1213
} from './handlers/auth/github';
1314
import { authJwks } from './handlers/auth/jwks';
1415

15-
const {
16-
version: appVersion,
17-
name: appName,
18-
description: appDescription
19-
} = await Bun.file('./package.json').json();
16+
const { version: appVersion, name: appName, description: appDescription } = packageJson;
2017

2118
export const app = new Elysia()
2219
.error({
@@ -64,4 +61,6 @@ export const app = new Elysia()
6461
)
6562
.listen(3000);
6663

67-
console.log(`🛰️ Juno API is running at ${app.server?.hostname}:${app.server?.port}`);
64+
console.log(
65+
`🛰️ Juno API (v${appVersion}) is running at ${app.server?.hostname}:${app.server?.port}`
66+
);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
] /* Specify type package names to be included without being referenced in a source file. */,
3838
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
3939
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
40-
// "resolveJsonModule": true, /* Enable importing .json files. */
40+
"resolveJsonModule": true /* Enable importing .json files. */,
4141
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
4242

4343
/* JavaScript Support */

0 commit comments

Comments
 (0)