Libraries
    Preparing search index...

    Function mapHandlers

    • Binds a complete set of endpoint builders to their handlers with compile-time exhaustiveness checking.

      TypeScript will report an error if any endpoint in endpoints is missing from handlers, or if a handler's signature does not match its endpoint. This is analogous to how @cleverbrush/mapper tracks unmapped properties at the type level.

      Type Parameters

      • TEndpoints extends Record<string, Record<string, AnyEndpoint | AnySubscriptionBuilder>>

      Parameters

      • endpoints: TEndpoints

        A grouped object of extended endpoint builders (e.g. after .authorize() / .inject()).

      • handlers: HandlerMap<TEndpoints>

        A matching grouped object of handler functions or { handler, middlewares } entries.

      Returns HandlerMapping

      A HandlerMapping to pass to ServerBuilder.handleAll().

      const mapping = mapHandlers(endpoints, {
      auth: {
      register: registerHandler,
      login: loginHandler,
      },
      todos: {
      list: listTodosHandler,
      create: createTodoHandler,
      export: { handler: exportHandler, middlewares: [auditLog] },
      },
      });

      server.handleAll(mapping);