15 lines
760 B
TypeScript
15 lines
760 B
TypeScript
/** Deployment-time connection overrides for immutable production images. */
|
|
export function productionConnections(value = process.env.WRNEXUS_RUNTIME_CONNECTIONS) {
|
|
if (!value) return {};
|
|
const parsed = JSON.parse(value);
|
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
throw new Error("WRNEXUS_RUNTIME_CONNECTIONS must be a JSON object");
|
|
const allowed = new Set(["db", "databases", "realtime", "queue", "storage"]);
|
|
for (const key of Object.keys(parsed)) {
|
|
if (!allowed.has(key)) throw new Error(`Unsupported runtime connection: ${key}`);
|
|
if (!parsed[key] || typeof parsed[key] !== "object" || Array.isArray(parsed[key]))
|
|
throw new Error(`Runtime connection ${key} must be an object`);
|
|
}
|
|
return parsed;
|
|
}
|