Change interval unit type to seconds

This commit is contained in:
pleb
2026-03-22 16:02:18 -07:00
parent 0531a23680
commit dc5023d272
4 changed files with 23 additions and 20 deletions
+15 -12
View File
@@ -27,15 +27,16 @@ export interface AppConfig {
warnings: string[];
}
const DEFAULT_PROBE_INTERVAL_MS = 0;
const DEFAULT_PROBE_TIMEOUT_MS = 10_000;
const MS_PER_SECOND = 1_000;
const DEFAULT_PROBE_INTERVAL_SECONDS = 0;
const DEFAULT_PROBE_TIMEOUT_SECONDS = 10;
const DEFAULT_LISTEN_ADDR = "0.0.0.0";
const DEFAULT_PORT = 9464;
const DEFAULT_LOG_LEVEL: LogLevel = "info";
const DEFAULT_WRITE_CHECK_ENABLED = true;
const DEFAULT_WRITE_CHECK_KIND = 30078;
const MIN_TIMEOUT_MS = 1_000;
const MIN_TIMEOUT_SECONDS = 1;
const MIN_PORT = 1;
const MAX_PORT = 65_535;
@@ -149,18 +150,20 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): AppConfig {
throw new Error("RELAYS did not contain any valid wss:// relay URLs");
}
const probeIntervalMs = parseInteger(
env.PROBE_INTERVAL_MS,
DEFAULT_PROBE_INTERVAL_MS,
const probeIntervalSeconds = parseInteger(
env.PROBE_INTERVAL_SECONDS,
DEFAULT_PROBE_INTERVAL_SECONDS,
0,
"PROBE_INTERVAL_MS",
"PROBE_INTERVAL_SECONDS",
);
const probeTimeoutMs = parseInteger(
env.PROBE_TIMEOUT_MS,
DEFAULT_PROBE_TIMEOUT_MS,
MIN_TIMEOUT_MS,
"PROBE_TIMEOUT_MS",
const probeTimeoutSeconds = parseInteger(
env.PROBE_TIMEOUT_SECONDS,
DEFAULT_PROBE_TIMEOUT_SECONDS,
MIN_TIMEOUT_SECONDS,
"PROBE_TIMEOUT_SECONDS",
);
const probeIntervalMs = probeIntervalSeconds * MS_PER_SECOND;
const probeTimeoutMs = probeTimeoutSeconds * MS_PER_SECOND;
const port = parseInteger(env.PORT, DEFAULT_PORT, MIN_PORT, "PORT");
if (port > MAX_PORT) {
throw new Error(`PORT must be <= ${MAX_PORT}`);