refactor: rename environment variables and update related configurations

- Updated environment variable names from JERAPAH_FLOW_* to JFLOW_* for consistency and clarity.
- Adjusted database path handling in knexfile.js to reflect the new variable naming.
- Modified logging and retention days configurations to use the new variable names.
- Ensured that the JWT secret and secrets key checks are aligned with the new naming convention.
- Updated workflow test storage prefix to match the new project branding.

This refactor enhances the clarity of environment variable usage and aligns with the project's rebranding efforts.
This commit is contained in:
2026-08-16 22:44:19 +07:00
parent e55f93e4d2
commit 56a5d0e7d2
7 changed files with 19 additions and 25 deletions
+1 -5
View File
@@ -2,12 +2,8 @@ import fs from "fs";
import path from "path";
import { DATA_DIR, SERVER_ROOT } from "./paths.js";
const defaultNew = path.join(DATA_DIR, "jerapah-flow.db");
const defaultLegacy = path.join(DATA_DIR, "scrunner.db");
const dbPath =
process.env.JERAPAH_FLOW_DB_PATH ??
process.env.SCRUNNER_DB_PATH ??
(fs.existsSync(defaultLegacy) && !fs.existsSync(defaultNew) ? defaultLegacy : defaultNew);
process.env.JFLOW_DB_PATH ?? path.join(DATA_DIR, "jerapah-flow.db");
fs.mkdirSync(path.dirname(dbPath), { recursive: true });
/** @type {import("knex").Knex.Config} */
+1 -1
View File
@@ -113,7 +113,7 @@ const rollingFile = pino.transport({
});
export const log = pino(
{ level: process.env.JERAPAH_FLOW_LOG_LEVEL ?? process.env.SCRUNNER_LOG_LEVEL ?? "debug" },
{ level: process.env.JFLOW_LOG_LEVEL ?? "debug" },
pino.multistream([
{ level: "debug", stream: redactStream(process.stdout) },
{ level: "debug", stream: redactStream(rollingFile) },
+1 -1
View File
@@ -323,7 +323,7 @@ export function createRegistry(server) {
pruneTask.destroy();
pruneTask = null;
}
const days = Number(process.env.JERAPAH_FLOW_RETENTION_DAYS ?? process.env.SCRUNNER_RETENTION_DAYS ?? 30);
const days = Number(process.env.JFLOW_RETENTION_DAYS ?? 30);
pruneTask = cron.schedule(
"0 0 * * *",
async () => {
+4 -5
View File
@@ -27,12 +27,11 @@ await migrate();
enableLogPersistence();
const jwtSecret =
process.env.JERAPAH_FLOW_JWT_SECRET ??
process.env.SCRUNNER_JWT_SECRET ??
(process.env.NODE_ENV === "production" ? "" : "scrunner-dev-secret");
process.env.JFLOW_JWT_SECRET ??
(process.env.NODE_ENV === "production" ? "" : "jflow-dev-secret");
if (!jwtSecret) {
log.error("JERAPAH_FLOW_JWT_SECRET is required in production");
log.error("JFLOW_JWT_SECRET is required in production");
process.exit(1);
}
@@ -54,7 +53,7 @@ await server.register(jwt, {
},
});
await server.register(cors, {
origin: process.env.JERAPAH_FLOW_CORS_ORIGIN ?? process.env.SCRUNNER_CORS_ORIGIN ?? "http://localhost:5173",
origin: process.env.JFLOW_CORS_ORIGIN ?? "http://localhost:5173",
credentials: true,
});
+4 -5
View File
@@ -1,7 +1,7 @@
import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from "node:crypto";
const DEV_DEFAULT = "scrunner-dev-secrets-key";
const SCRYPT_SALT = Buffer.from("scrunner-secrets-v1");
const DEV_DEFAULT = "jflow-dev-secrets-key";
const SCRYPT_SALT = Buffer.from("jflow-secrets-v1");
const KEY_LEN = 32;
const IV_LEN = 12;
const AUTH_TAG_LEN = 16;
@@ -11,11 +11,10 @@ const AUTH_TAG_LEN = 16;
*/
export function resolveSecretsKeyMaterial() {
const raw =
process.env.JERAPAH_FLOW_SECRETS_KEY ??
process.env.SCRUNNER_SECRETS_KEY ??
process.env.JFLOW_SECRETS_KEY ??
(process.env.NODE_ENV === "production" ? "" : DEV_DEFAULT);
if (!raw) {
throw new Error("JERAPAH_FLOW_SECRETS_KEY is required in production");
throw new Error("JFLOW_SECRETS_KEY is required in production");
}
return raw;
}