Skip to content

Commit 98a1197

Browse files
committed
build(server): set development TLS
1 parent d201caa commit 98a1197

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"module": "build/server.js",
77
"type": "module",
88
"scripts": {
9-
"dev": "GRAPHILE_ENV=development bun run --watch src/server.ts",
9+
"dev": "NODE_ENV=development GRAPHILE_ENV=development bun run --watch src/server.ts",
1010
"build": "bun build --target node --outdir build src/server.ts",
1111
"start": "NODE_ENV=production GRAPHILE_ENV=production bun db:migrate && NODE_ENV=production GRAPHILE_ENV=production bun run build/server.js",
1212
"lint": "biome lint src",
@@ -24,7 +24,9 @@
2424
"graphile:generate": "NODE_ENV=development GRAPHILE_ENV=development bun run --env-file .env.local src/scripts/generateGraphqlSchema.ts",
2525
"prepare": "husky"
2626
},
27-
"trustedDependencies": ["@biomejs/biome"],
27+
"trustedDependencies": [
28+
"@biomejs/biome"
29+
],
2830
"devDependencies": {
2931
"@biomejs/biome": "^1.9.4",
3032
"@types/bun": "^1.2.13",

src/server.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,30 @@ import { useGrafast } from "grafast/envelop";
99

1010
import { schema } from "generated/graphql/schema.executable";
1111
import appConfig from "lib/config/app.config";
12-
import { CORS_ALLOWED_ORIGINS, PORT, isProdEnv } from "lib/config/env.config";
12+
import {
13+
CORS_ALLOWED_ORIGINS,
14+
PORT,
15+
isDevEnv,
16+
isProdEnv,
17+
} from "lib/config/env.config";
1318
import createGraphqlContext from "lib/graphql/createGraphqlContext";
1419
import { armorPlugins, useAuth } from "lib/graphql/plugins";
1520

1621
/**
1722
* Elysia server.
1823
*/
1924
const app = new Elysia({
20-
serve: {
21-
// https://elysiajs.com/patterns/configuration#serve-tls
22-
// https://bun.sh/guides/http/tls
23-
// NB: Elysia (and Bun) trust the well-known CA list curated by Mozilla (https://wiki.mozilla.org/CA/Included_Certificates), but they can be customized here if needed (`tls.ca` option)
24-
tls: {
25-
certFile: "cert.pem",
26-
keyFile: "key.pem",
25+
...(isDevEnv && {
26+
serve: {
27+
// https://elysiajs.com/patterns/configuration#serve-tls
28+
// https://bun.sh/guides/http/tls
29+
// NB: Elysia (and Bun) trust the well-known CA list curated by Mozilla (https://wiki.mozilla.org/CA/Included_Certificates), but they can be customized here if needed (`tls.ca` option)
30+
tls: {
31+
certFile: "cert.pem",
32+
keyFile: "key.pem",
33+
},
2734
},
28-
},
35+
}),
2936
})
3037
.use(
3138
cors({

0 commit comments

Comments
 (0)