forked from wangziqi/gongxue-base
feat: add crm webhook worker
This commit is contained in:
25
apps/worker/src/config.ts
Normal file
25
apps/worker/src/config.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { DEFAULT_DATABASE_URL, envBoolean, envList, envNumber, envString, loadDotenv } from '../../../packages/config/src/index.js';
|
||||
|
||||
loadDotenv();
|
||||
|
||||
export interface WorkerConfig {
|
||||
databaseUrl: string;
|
||||
crmBatchSize: number;
|
||||
crmPollIntervalMs: number;
|
||||
crmMaxAttempts: number;
|
||||
crmBackoffSeconds: number[];
|
||||
crmRequestTimeoutMs: number;
|
||||
crmAllowInsecureLocalhost: boolean;
|
||||
}
|
||||
|
||||
export const config: WorkerConfig = {
|
||||
databaseUrl: envString('DATABASE_URL', DEFAULT_DATABASE_URL),
|
||||
crmBatchSize: envNumber('WORKER_CRM_BATCH_SIZE', 20),
|
||||
crmPollIntervalMs: envNumber('WORKER_CRM_POLL_INTERVAL_MS', 10_000),
|
||||
crmMaxAttempts: envNumber('WORKER_CRM_MAX_ATTEMPTS', 5),
|
||||
crmBackoffSeconds: envList('WORKER_CRM_BACKOFF_SECONDS', '5,30,120,600,1800')
|
||||
.map((value: string) => Number(value))
|
||||
.filter((value: number) => Number.isFinite(value) && value > 0),
|
||||
crmRequestTimeoutMs: envNumber('WORKER_CRM_REQUEST_TIMEOUT_MS', 10_000),
|
||||
crmAllowInsecureLocalhost: envBoolean('WORKER_CRM_ALLOW_INSECURE_LOCALHOST', false),
|
||||
};
|
||||
Reference in New Issue
Block a user