-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
59 lines (51 loc) · 1.95 KB
/
Copy pathserver.js
File metadata and controls
59 lines (51 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Process entrypoint.
//
// Responsibilities are intentionally narrow:
// 1. Load env
// 2. Build config
// 3. Build the app (see server/app.mjs)
// 4. Validate on-disk schema
// 5. Bind a port (unless QA_TEST_MODE=1)
//
// All routes, middleware, and business logic live under server/. Tests
// import { app } from this file so QA_TEST_MODE must remain the gate
// that prevents listen() from running at module load.
import path from "node:path";
import { fileURLToPath } from "node:url";
import { createApp } from "./server/app.mjs";
import {
buildConfig,
getRuntimeMode,
hasOpenAiConfig,
hasRealQaBackendConfig,
hasRealJiraConfig,
hasRealSlackConfig,
hasRealZohoCliqConfig,
hasSessionSecret,
warnOnPartialConfig,
} from "./server/config.mjs";
import { loadEnv } from "./server/loadEnv.mjs";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
await loadEnv(__dirname);
const config = buildConfig({ rootDir: __dirname });
const { app, accounts } = createApp(config);
await accounts.assertSchema();
export { app };
if (!process.env.QA_TEST_MODE) {
app.listen(config.port, () => {
warnOnPartialConfig(config);
if (config.isProduction && !hasSessionSecret(config)) {
console.error("SESSION_SECRET is required in production.");
process.exit(1);
}
console.log(`QA Tool backend listening on http://localhost:${config.port}`);
console.log(`Mode: ${getRuntimeMode(config)}`);
console.log(` QA Tool: ${hasRealQaBackendConfig(config) ? "live" : "demo"}`);
console.log(` Jira: ${hasRealJiraConfig(config) ? "live" : "demo"}`);
console.log(` Slack: ${hasRealSlackConfig(config) ? "live" : "demo"}`);
console.log(` Zoho Cliq: ${hasRealZohoCliqConfig(config) ? "live" : "demo"}`);
console.log(` OpenAI: ${hasOpenAiConfig(config) ? "live" : "demo"}`);
console.log(` Demo mode: ${config.allowDemoMode ? "enabled" : "disabled"}`);
});
}