Skip to content

Commit 937ebab

Browse files
authored
Merge pull request #2 from gosuda/dev
fix(server): default serve script to explicit development mode
2 parents 46d1760 + 3de5212 commit 937ebab

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bun run serve
2626
bun run dev
2727
```
2828

29-
The development fallback secret is intentionally insecure. Set `TGB_SECRET` to at least 16 characters for a real deployment; production mode refuses to start without it. Set `TGB_DATA_DIR` to move persistent tenant data outside the repository.
29+
The development fallback secret is intentionally insecure, and `bun run serve` defaults to explicit development mode so the local quickstart uses it with a loud warning. Any other invocation refuses to start unless `TGB_SECRET` is at least 16 characters or the mode is explicitly development/test; production mode always refuses to start without a strong `TGB_SECRET`. Set `TGB_DATA_DIR` to move persistent tenant data outside the repository.
3030

3131
## Commands
3232

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Elastic-2.0",
77
"scripts": {
88
"dev": "vite",
9-
"serve": "bun run server/index.ts",
9+
"serve": "TGB_ENV=\"${TGB_ENV:-development}\" bun run server/index.ts",
1010
"build": "vite build && bun run scripts/build-runtime.ts && bun run scripts/build-games.ts",
1111
"build:wasm": "bun run scripts/build-wasm.ts",
1212
"typecheck": "tsc --noEmit",

server/auth.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readFileSync } from "node:fs";
12
import { afterEach, describe, expect, test, vi } from "vitest";
23
import { issueToken } from "@/agentapi/credentials";
34
import type { CredentialClaims } from "@/model/types";
@@ -76,4 +77,11 @@ describe("server bearer auth", () => {
7677
expect(() => loadSecret({ NODE_ENV: "development", TGB_SECRET: "short" })).not.toThrow();
7778
expect(loadSecret({ NODE_ENV: "production", TGB_SECRET: SECRET })).toBe(SECRET);
7879
});
80+
81+
test("serve script opts into explicit development mode without overriding an operator's TGB_ENV", () => {
82+
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as {
83+
scripts: Record<string, string>;
84+
};
85+
expect(pkg.scripts.serve).toContain('TGB_ENV="$' + '{TGB_ENV:-development}"');
86+
});
7987
});

0 commit comments

Comments
 (0)