BOT_FIRE_CONCURRENCY (8) — pg-boss worker pool size, gates max accounts firing fan-outs in parallel. BOT_GROUP_CONCURRENCY (3) — per-account parallel group sends; parts within a group stay serial so chat order is preserved. BOT_MAX_SEND_PER_MINUTE (40) — per-account token-bucket rate. Defaults are tuned for an established WhatsApp account (~30-60 msg/min safe band). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { z } from "zod";
|
|
|
|
const numberFromString = z.string().regex(/^\d+$/).transform((s) => Number(s));
|
|
|
|
const envSchema = z.object({
|
|
DATABASE_URL: z.string().url(),
|
|
DATA_DIR: z.string().min(1),
|
|
SESSIONS_DIR: z.string().min(1),
|
|
MEDIA_DIR: z.string().min(1),
|
|
BOT_HEALTH_PORT: numberFromString,
|
|
BOT_LOG_LEVEL: z.enum(["fatal", "error", "warn", "info", "debug", "trace"]).default("info"),
|
|
|
|
// Reminder fan-out tuning. Defaults aim for an established WhatsApp
|
|
// account (~30-60 msg/min safe band).
|
|
// BOT_FIRE_CONCURRENCY — pg-boss worker pool: max accounts firing in parallel.
|
|
// BOT_GROUP_CONCURRENCY — per-account parallel group sends; parts within a group stay serial.
|
|
// BOT_MAX_SEND_PER_MINUTE — per-account token-bucket rate.
|
|
BOT_FIRE_CONCURRENCY: numberFromString.default("8"),
|
|
BOT_GROUP_CONCURRENCY: numberFromString.default("3"),
|
|
BOT_MAX_SEND_PER_MINUTE: numberFromString.default("40"),
|
|
});
|
|
|
|
export type Env = z.infer<typeof envSchema>;
|
|
|
|
export function parseEnv(input: Record<string, string | undefined>): Env {
|
|
return envSchema.parse(input);
|
|
}
|
|
|
|
export const env = parseEnv(process.env);
|