feat: validate production runtime config

This commit is contained in:
2026-07-19 12:47:42 +08:00
parent bc58981de2
commit 6a10ddb6e5
6 changed files with 30 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { checkRuntimeConfig } from "../lib/config";
test("requires secure production secrets and a public HTTPS origin", () => {
assert.equal(checkRuntimeConfig({ NODE_ENV: "production", SESSION_SECRET: "x".repeat(32), TOKEN_ENCRYPTION_KEY: "a".repeat(64), NEXT_PUBLIC_APP_URL: "https://hub.example.test" }).ok, true);
const invalid = checkRuntimeConfig({ NODE_ENV: "production", SESSION_SECRET: "development-only-change-me", TOKEN_ENCRYPTION_KEY: "wrong", NEXT_PUBLIC_APP_URL: "http://localhost:8088" });
assert.equal(invalid.ok, false); assert.equal(invalid.errors.length, 3);
assert.equal(checkRuntimeConfig({ NODE_ENV: "test" }).ok, true);
});