Libraries
    Preparing search index...

    Fluent builder for constructing and starting an HTTP server.

    const server = new ServerBuilder();

    server
    .services(svc => svc.addSingleton(IDb, () => new Db()))
    .use(loggingMiddleware)
    .handle(GetUser, ({ params }) => db.find(params.id));

    await server.listen(3000);
    Index

    Constructors

    Methods

    • Register an endpoint and its handler.

      Type Parameters

      Parameters

      • endpointDef: E

        An EndpointBuilder instance (e.g. from endpoint.get(...)).

      • handler: Handler<E>

        The typed handler function.

      • Optionaloptions: { middlewares?: Middleware[] }

        Optional per-endpoint middleware.

      Returns this

    • Start listening on the given port and host. Resolves with the running Server instance.

      Parameters

      • Optionalport: number

        TCP port (default: ServerOptions.port ?? 3000).

      • Optionalhost: string

        Bind address (default: ServerOptions.host ?? '0.0.0.0').

      Returns Promise<Server>

    • Enable the server-side request batching endpoint.

      Once enabled, the server accepts POST <path> (default /__batch) containing an array of sub-requests and processes each one through the full middleware and handler pipeline, returning an array of sub-responses in a single HTTP reply.

      Pair this with the batching() middleware from @cleverbrush/client/batching on the client side.

      Parameters

      Returns this

      new ServerBuilder()
      .useBatching()
      .handleAll(mapping)
      .listen(3000);
    • Enable the GET /health endpoint that returns { ok: true } (200). Useful for load balancer and container readiness probes.

      Returns this