feat: expand production config and documentation for provider integrations
This commit is contained in:
@@ -8,13 +8,25 @@ test("config uses defaults when env is missing", () => {
|
||||
PORT: process.env.PORT,
|
||||
STATE_FILE_PATH: process.env.STATE_FILE_PATH,
|
||||
LOG_LEVEL: process.env.LOG_LEVEL,
|
||||
APP_BASE_URL: process.env.APP_BASE_URL,
|
||||
TTS_MODEL: process.env.TTS_MODEL,
|
||||
S3_SIGNED_URL_TTL_SEC: process.env.S3_SIGNED_URL_TTL_SEC,
|
||||
X_BOT_USER_ID: process.env.X_BOT_USER_ID,
|
||||
WEBHOOK_RPM: process.env.WEBHOOK_RPM,
|
||||
POLAR_SERVER: process.env.POLAR_SERVER,
|
||||
POLAR_PRODUCT_IDS: process.env.POLAR_PRODUCT_IDS,
|
||||
};
|
||||
|
||||
delete process.env.PORT;
|
||||
delete process.env.STATE_FILE_PATH;
|
||||
delete process.env.LOG_LEVEL;
|
||||
delete process.env.APP_BASE_URL;
|
||||
delete process.env.TTS_MODEL;
|
||||
delete process.env.S3_SIGNED_URL_TTL_SEC;
|
||||
delete process.env.X_BOT_USER_ID;
|
||||
delete process.env.WEBHOOK_RPM;
|
||||
delete process.env.POLAR_SERVER;
|
||||
delete process.env.POLAR_PRODUCT_IDS;
|
||||
|
||||
delete require.cache[require.resolve("../src/config")];
|
||||
const { config } = require("../src/config");
|
||||
@@ -22,6 +34,12 @@ test("config uses defaults when env is missing", () => {
|
||||
assert.equal(config.port, 3000);
|
||||
assert.equal(config.stateFilePath, "./data/state.json");
|
||||
assert.equal(config.logLevel, "info");
|
||||
assert.equal(config.appBaseUrl, "http://localhost:3000");
|
||||
assert.equal(config.ttsModel, "gpt-4o-mini-tts");
|
||||
assert.equal(config.s3SignedUrlTtlSec, 3600);
|
||||
assert.equal(config.xBotUserId, "");
|
||||
assert.equal(config.polarServer, "production");
|
||||
assert.deepEqual(config.polarProductIds, []);
|
||||
assert.equal(config.rateLimits.webhookPerMinute, 120);
|
||||
|
||||
if (previous.PORT === undefined) {
|
||||
@@ -42,11 +60,47 @@ test("config uses defaults when env is missing", () => {
|
||||
process.env.LOG_LEVEL = previous.LOG_LEVEL;
|
||||
}
|
||||
|
||||
if (previous.APP_BASE_URL === undefined) {
|
||||
delete process.env.APP_BASE_URL;
|
||||
} else {
|
||||
process.env.APP_BASE_URL = previous.APP_BASE_URL;
|
||||
}
|
||||
|
||||
if (previous.TTS_MODEL === undefined) {
|
||||
delete process.env.TTS_MODEL;
|
||||
} else {
|
||||
process.env.TTS_MODEL = previous.TTS_MODEL;
|
||||
}
|
||||
|
||||
if (previous.S3_SIGNED_URL_TTL_SEC === undefined) {
|
||||
delete process.env.S3_SIGNED_URL_TTL_SEC;
|
||||
} else {
|
||||
process.env.S3_SIGNED_URL_TTL_SEC = previous.S3_SIGNED_URL_TTL_SEC;
|
||||
}
|
||||
|
||||
if (previous.X_BOT_USER_ID === undefined) {
|
||||
delete process.env.X_BOT_USER_ID;
|
||||
} else {
|
||||
process.env.X_BOT_USER_ID = previous.X_BOT_USER_ID;
|
||||
}
|
||||
|
||||
if (previous.WEBHOOK_RPM === undefined) {
|
||||
delete process.env.WEBHOOK_RPM;
|
||||
} else {
|
||||
process.env.WEBHOOK_RPM = previous.WEBHOOK_RPM;
|
||||
}
|
||||
|
||||
if (previous.POLAR_SERVER === undefined) {
|
||||
delete process.env.POLAR_SERVER;
|
||||
} else {
|
||||
process.env.POLAR_SERVER = previous.POLAR_SERVER;
|
||||
}
|
||||
|
||||
if (previous.POLAR_PRODUCT_IDS === undefined) {
|
||||
delete process.env.POLAR_PRODUCT_IDS;
|
||||
} else {
|
||||
process.env.POLAR_PRODUCT_IDS = previous.POLAR_PRODUCT_IDS;
|
||||
}
|
||||
});
|
||||
|
||||
test("config reads state path and numeric env overrides", () => {
|
||||
@@ -55,12 +109,24 @@ test("config reads state path and numeric env overrides", () => {
|
||||
STATE_FILE_PATH: process.env.STATE_FILE_PATH,
|
||||
LOG_LEVEL: process.env.LOG_LEVEL,
|
||||
WEBHOOK_RPM: process.env.WEBHOOK_RPM,
|
||||
APP_BASE_URL: process.env.APP_BASE_URL,
|
||||
TTS_MODEL: process.env.TTS_MODEL,
|
||||
S3_SIGNED_URL_TTL_SEC: process.env.S3_SIGNED_URL_TTL_SEC,
|
||||
X_BOT_USER_ID: process.env.X_BOT_USER_ID,
|
||||
POLAR_SERVER: process.env.POLAR_SERVER,
|
||||
POLAR_PRODUCT_IDS: process.env.POLAR_PRODUCT_IDS,
|
||||
};
|
||||
|
||||
process.env.PORT = "8080";
|
||||
process.env.STATE_FILE_PATH = "/data/prod-state.json";
|
||||
process.env.LOG_LEVEL = "debug";
|
||||
process.env.APP_BASE_URL = "https://xartaudio.app";
|
||||
process.env.TTS_MODEL = "custom-tts";
|
||||
process.env.S3_SIGNED_URL_TTL_SEC = "7200";
|
||||
process.env.X_BOT_USER_ID = "bot-user-id";
|
||||
process.env.WEBHOOK_RPM = "77";
|
||||
process.env.POLAR_SERVER = "sandbox";
|
||||
process.env.POLAR_PRODUCT_IDS = "prod_1,prod_2";
|
||||
|
||||
delete require.cache[require.resolve("../src/config")];
|
||||
const { config } = require("../src/config");
|
||||
@@ -68,6 +134,12 @@ test("config reads state path and numeric env overrides", () => {
|
||||
assert.equal(config.port, 8080);
|
||||
assert.equal(config.stateFilePath, "/data/prod-state.json");
|
||||
assert.equal(config.logLevel, "debug");
|
||||
assert.equal(config.appBaseUrl, "https://xartaudio.app");
|
||||
assert.equal(config.ttsModel, "custom-tts");
|
||||
assert.equal(config.s3SignedUrlTtlSec, 7200);
|
||||
assert.equal(config.xBotUserId, "bot-user-id");
|
||||
assert.equal(config.polarServer, "sandbox");
|
||||
assert.deepEqual(config.polarProductIds, ["prod_1", "prod_2"]);
|
||||
assert.equal(config.rateLimits.webhookPerMinute, 77);
|
||||
|
||||
if (previous.PORT === undefined) {
|
||||
@@ -86,9 +158,46 @@ test("config reads state path and numeric env overrides", () => {
|
||||
} else {
|
||||
process.env.LOG_LEVEL = previous.LOG_LEVEL;
|
||||
}
|
||||
|
||||
if (previous.APP_BASE_URL === undefined) {
|
||||
delete process.env.APP_BASE_URL;
|
||||
} else {
|
||||
process.env.APP_BASE_URL = previous.APP_BASE_URL;
|
||||
}
|
||||
|
||||
if (previous.TTS_MODEL === undefined) {
|
||||
delete process.env.TTS_MODEL;
|
||||
} else {
|
||||
process.env.TTS_MODEL = previous.TTS_MODEL;
|
||||
}
|
||||
|
||||
if (previous.S3_SIGNED_URL_TTL_SEC === undefined) {
|
||||
delete process.env.S3_SIGNED_URL_TTL_SEC;
|
||||
} else {
|
||||
process.env.S3_SIGNED_URL_TTL_SEC = previous.S3_SIGNED_URL_TTL_SEC;
|
||||
}
|
||||
|
||||
if (previous.X_BOT_USER_ID === undefined) {
|
||||
delete process.env.X_BOT_USER_ID;
|
||||
} else {
|
||||
process.env.X_BOT_USER_ID = previous.X_BOT_USER_ID;
|
||||
}
|
||||
|
||||
if (previous.WEBHOOK_RPM === undefined) {
|
||||
delete process.env.WEBHOOK_RPM;
|
||||
} else {
|
||||
process.env.WEBHOOK_RPM = previous.WEBHOOK_RPM;
|
||||
}
|
||||
|
||||
if (previous.POLAR_SERVER === undefined) {
|
||||
delete process.env.POLAR_SERVER;
|
||||
} else {
|
||||
process.env.POLAR_SERVER = previous.POLAR_SERVER;
|
||||
}
|
||||
|
||||
if (previous.POLAR_PRODUCT_IDS === undefined) {
|
||||
delete process.env.POLAR_PRODUCT_IDS;
|
||||
} else {
|
||||
process.env.POLAR_PRODUCT_IDS = previous.POLAR_PRODUCT_IDS;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,8 +17,15 @@ test("Dockerfile contains production container essentials", () => {
|
||||
test("env example includes required webhook and credit settings", () => {
|
||||
const envFile = fs.readFileSync(".env.example", "utf8");
|
||||
assert.match(envFile, /LOG_LEVEL=/);
|
||||
assert.match(envFile, /APP_BASE_URL=/);
|
||||
assert.match(envFile, /X_WEBHOOK_SECRET=/);
|
||||
assert.match(envFile, /X_BEARER_TOKEN=/);
|
||||
assert.match(envFile, /X_BOT_USER_ID=/);
|
||||
assert.match(envFile, /POLAR_WEBHOOK_SECRET=/);
|
||||
assert.match(envFile, /POLAR_ACCESS_TOKEN=/);
|
||||
assert.match(envFile, /POLAR_PRODUCT_IDS=/);
|
||||
assert.match(envFile, /TTS_API_KEY=/);
|
||||
assert.match(envFile, /S3_BUCKET=/);
|
||||
assert.match(envFile, /INCLUDED_CHARS=/);
|
||||
assert.match(envFile, /WEBHOOK_RPM=/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user