Fork Horse repository, listed by its owner. Publisher snapshot.
scripts/gatekeeper-deployment.ts
Snapshot at 34e3175
1import type { DeploymentConfig } from "./deployment-config.ts";
2
3/** Optional private vendor. This switch wires the Worker; it does not enable accounts. */
4export interface ForkhorseGatekeeperDeployment {
5 enabled: boolean;
6 workerName: string;
7}
8
9export function validateForkhorseGatekeeper(config: DeploymentConfig): void {
10 const gatekeeper = config.forkhorseGatekeeper;
11 if (gatekeeper === undefined) return;
12 if (!gatekeeper || typeof gatekeeper.enabled !== "boolean") {
13 throw new Error("forkhorseGatekeeper.enabled must be a boolean.");
14 }
15 if (!gatekeeper.enabled) return;
16 if (typeof gatekeeper.workerName !== "string" ||
17 !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(gatekeeper.workerName)) {
18 throw new Error("forkhorseGatekeeper.workerName must use lowercase letters, numbers and hyphens.");
19 }
20 const names = Object.entries(config.workers)
21 .filter(([key]) => key !== "customGatekeeper")
22 .filter(([key]) => key !== "errorReporter" || config.errorReporting.enabled)
23 .map(([, worker]) => worker.name);
24 if (config.core?.enabled) names.push(config.core.workerName);
25 if (names.includes(gatekeeper.workerName)) {
26 throw new Error("forkhorseGatekeeper.workerName must be unique.");
27 }
28}
29