MCPcopy Create free account
hub / github.com/Effect-TS/effect / registerHandler

Function registerHandler

packages/effect/src/unstable/httpapi/HttpApiBuilder.ts:584–607  ·  view source on GitHub ↗
(
  self: Handlers<any, any, any>,
  identifier: string,
  handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>,
  isRaw: boolean,
  options?: HandlerOptions | undefined
)

Source from the content-addressed store, hash-verified

582}
583
584const registerHandler = (
585 self: Handlers<any, any, any>,
586 identifier: string,
587 handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>,
588 isRaw: boolean,
589 options?: HandlerOptions | undefined
590) => {
591 if (!Object.hasOwn(self.group.endpoints, identifier)) {
592 throw new Error(`HttpApiEndpoint "${identifier}" not found in HttpApiGroup "${self.group.identifier}"`)
593 }
594 if (self.handlers.has(identifier)) {
595 throw new Error(
596 `Handler for HttpApiEndpoint "${identifier}" is already registered in HttpApiGroup "${self.group.identifier}"`
597 )
598 }
599 const endpoint = self.group.endpoints[identifier]
600 self.handlers.set(identifier, {
601 endpoint,
602 handler,
603 isRaw,
604 uninterruptible: options?.uninterruptible ?? false
605 })
606 return self
607}
608
609const HandlersProto = {
610 [HandlersTypeId]: HandlersTypeId,

Callers 3

handleFunction · 0.85
handleAllFunction · 0.85
handleRawFunction · 0.85

Calls 2

setMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected