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

Function createRuntimeHandler

packages/agents-runtime/src/create-handler.ts:655–702  ·  view source on GitHub ↗
(
  config: RuntimeHandlerConfig
)

Source from the content-addressed store, hash-verified

653}
654
655export function createRuntimeHandler(
656 config: RuntimeHandlerConfig
657): RuntimeHandler {
658 const router = createRuntimeRouter(config)
659
660 const onEnter = async (
661 req: IncomingMessage,
662 res: ServerResponse
663 ): Promise<void> => {
664 let request: Request
665 try {
666 request = await toFetchRequest(req)
667 } catch (err) {
668 await sendNodeResponse(
669 res,
670 json(
671 {
672 error: `Request body read failed`,
673 details: err instanceof Error ? err.message : String(err),
674 },
675 400
676 )
677 )
678 return
679 }
680
681 const response = await router.handleWebhookRequest(request)
682 await sendNodeResponse(res, response)
683 }
684
685 return {
686 onEnter,
687 handleRequest: router.handleRequest,
688 handleWebhookRequest: router.handleWebhookRequest,
689 dispatchWake: router.dispatchWake,
690 isWakeActive: router.isWakeActive,
691 dispatchWebhookWake: router.dispatchWebhookWake,
692 drainWakes: router.drainWakes,
693 waitForSettled: router.waitForSettled,
694 abortWakes: router.abortWakes,
695 debugState: router.debugState,
696 get typeNames() {
697 return router.typeNames
698 },
699 sandboxProfileDescriptors: router.sandboxProfileDescriptors,
700 registerTypes: router.registerTypes,
701 }
702}
703
704function normalizeConfig(config: RuntimeRouterConfig): {
705 baseUrl: string

Callers 14

createMockAgentBootstrapFunction · 0.90
server.tsFile · 0.90
server.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index1.tsFile · 0.90
index5.tsFile · 0.90
index3.tsFile · 0.90
index4.tsFile · 0.90

Calls 1

createRuntimeRouterFunction · 0.85

Tested by

no test coverage detected