MCPcopy Create free account
hub / github.com/electric-sql/electric / normalizeConfig

Function normalizeConfig

packages/agents-runtime/src/create-handler.ts:704–751  ·  view source on GitHub ↗
(config: RuntimeRouterConfig)

Source from the content-addressed store, hash-verified

702}
703
704function normalizeConfig(config: RuntimeRouterConfig): {
705 baseUrl: string
706 serveEndpoint?: string
707 webhookPath: string
708 registry?: EntityRegistry
709 subscriptionPathForType?: (typeName: string) => string
710 defaultDispatchPolicyForType?: RuntimeRouterConfig[`defaultDispatchPolicyForType`]
711 serverHeaders?: RuntimeRouterConfig[`serverHeaders`]
712 idleTimeout?: number
713 heartbeatInterval?: number
714 createElectricTools?: RuntimeRouterConfig[`createElectricTools`]
715 registrationConcurrency?: number
716 publicUrl?: string
717 name?: string
718 webhookSignature: false | WebhookSignatureVerifierConfig
719} {
720 const serveEndpoint = config.serveEndpoint ?? config.handlerUrl
721 const webhookPath =
722 config.webhookPath ?? getPathname(serveEndpoint) ?? `/electric-agents`
723 const webhookSignature =
724 config.webhookSignature === false
725 ? false
726 : {
727 jwksUrl:
728 config.webhookSignature?.jwksUrl ??
729 appendPathToUrl(config.baseUrl, `/__ds/jwks.json`),
730 toleranceSeconds: config.webhookSignature?.toleranceSeconds,
731 cacheTtlMs: config.webhookSignature?.cacheTtlMs,
732 fetchClient: config.webhookSignature?.fetchClient,
733 }
734
735 return {
736 baseUrl: config.baseUrl,
737 serveEndpoint,
738 webhookPath,
739 registry: config.registry,
740 subscriptionPathForType: config.subscriptionPathForType,
741 defaultDispatchPolicyForType: config.defaultDispatchPolicyForType,
742 serverHeaders: config.serverHeaders,
743 idleTimeout: config.idleTimeout,
744 heartbeatInterval: config.heartbeatInterval,
745 createElectricTools: config.createElectricTools,
746 registrationConcurrency: config.registrationConcurrency,
747 publicUrl: config.publicUrl,
748 name: config.name,
749 webhookSignature,
750 }
751}
752
753function runtimeWebhookSubscriptionId(typeName: string): string {
754 const safeTypeName = typeName.replace(/[^A-Za-z0-9_.-]/g, `_`)

Callers 1

createRuntimeRouterFunction · 0.85

Calls 2

appendPathToUrlFunction · 0.90
getPathnameFunction · 0.85

Tested by

no test coverage detected