Beignet API reference
    Preparing search index...

    Interface FetchServer<Ctx, Ports, ServiceInput>

    Beignet server adapted to the Web Fetch API.

    interface FetchServer<
        Ctx,
        Ports extends AnyPorts = AnyPorts,
        ServiceInput = void,
    > {
        api: (req: Request) => Promise<Response>;
        contracts: readonly ContractLike[];
        createRequestContext: (req: HttpRequestLike) => Promise<Ctx>;
        createServiceContext: (
            ...args: ServiceContextInputArgs<ServiceInput>,
        ) => Promise<Ctx>;
        fetch: (req: Request) => Promise<Response>;
        ports: Ports;
        rawRoute: (
            init: RawRouteInit,
        ) => {
            handle: (
                fn: Handler<Ctx, HttpContractConfig>,
            ) => (req: Request) => Promise<Response>;
        };
        route: <CLike extends ContractLike>(
            contractLike: CLike,
        ) => {
            handle: (
                fn: Handler<Ctx, ResolveContract<CLike>>,
            ) => (req: Request) => Promise<Response>;
        };
        stop: () => Promise<void>;
    }

    Type Parameters

    Index
    api: (req: Request) => Promise<Response>

    Alias for fetch for API route adapters that expect an api property.

    contracts: readonly ContractLike[]

    Registered contract inputs.

    createRequestContext: (req: HttpRequestLike) => Promise<Ctx>

    Build a fully assembled request context from a framework-neutral request.

    createServiceContext: (
        ...args: ServiceContextInputArgs<ServiceInput>,
    ) => Promise<Ctx>

    Build a fully assembled service context for schedules, outbox drains, commands, and background work.

    fetch: (req: Request) => Promise<Response>

    Catch-all Web Fetch handler.

    ports: Ports

    Final app ports after provider setup.

    rawRoute: (
        init: RawRouteInit,
    ) => {
        handle: (
            fn: Handler<Ctx, HttpContractConfig>,
        ) => (req: Request) => Promise<Response>;
    }

    Build a Web Fetch handler for a route that cannot be a contract while still running the whole server pipeline — hooks, context creation, instrumentation, and framework error mapping. Request parsing is skipped and the body is left unconsumed for the handler. Raw routes are not added to the route registry; mount the returned handler yourself.

    route: <CLike extends ContractLike>(
        contractLike: CLike,
    ) => {
        handle: (
            fn: Handler<Ctx, ResolveContract<CLike>>,
        ) => (req: Request) => Promise<Response>;
    }

    Register and build a single Web Fetch route handler imperatively.

    stop: () => Promise<void>

    Stop installed providers.