feat: add configurable persistent state file path and env tests

This commit is contained in:
Codex
2026-02-18 12:59:56 +00:00
parent c714c2eaec
commit fc7ded3f38
2 changed files with 66 additions and 0 deletions

View File

@@ -10,8 +10,14 @@ function intFromEnv(name, fallback) {
return Number.isInteger(parsed) ? parsed : fallback;
}
function strFromEnv(name, fallback) {
const raw = process.env[name];
return raw && String(raw).trim() ? String(raw).trim() : fallback;
}
const config = {
port: intFromEnv("PORT", 3000),
stateFilePath: strFromEnv("STATE_FILE_PATH", "./data/state.json"),
xWebhookSecret: process.env.X_WEBHOOK_SECRET || "dev-x-secret",
polarWebhookSecret: process.env.POLAR_WEBHOOK_SECRET || "dev-polar-secret",
credit: {