Beignet API reference
    Preparing search index...

    Type Alias CreateServerOptions<Ctx, Ports, ServiceInput, Routes, Providers>

    Options for creating a Beignet server instance.

    type CreateServerOptions<
        Ctx,
        Ports extends AnyPorts,
        ServiceInput = void,
        Routes extends
            readonly RouteDef<any, any>[] = readonly RouteDef<any, any>[],
        Providers extends readonly AnyServiceProvider[] = readonly [],
    > = {
        context: ServerContextConfig<
            Ctx,
            Ports & InferProviderPorts<Providers>,
            ServiceInput,
        >;
        hooks?: ServerHook<Ctx, Ports & InferProviderPorts<Providers>>[];
        instrumentation?: ServerInstrumentationOptions<Ctx> | false;
        integrity?: RuntimeIntegrityCheck;
        mapUnhandledError?: ServerUnhandledErrorMapper<Ctx>;
        onCaughtError?: ServerCaughtErrorHook<Ctx>;
        onUnboundPorts?: "error" | "warn" | "ignore";
        ports: Ports;
        providerConfig?: Record<string, unknown>;
        providerEnv?: Record<string, string | undefined>;
        providers?: Providers;
        requestBody?: RequestBodyOptions;
        routes?: Routes;
        validateResponses?: boolean;
    }

    Type Parameters

    • Ctx
    • Ports extends AnyPorts
    • ServiceInput = void
    • Routes extends readonly RouteDef<any, any>[] = readonly RouteDef<any, any>[]
    • Providers extends readonly AnyServiceProvider[] = readonly []
    Index

    Context blueprint for request and service contexts.

    Gate-less contexts may pass a plain request factory. Contexts with a gate property must use the blueprint form { gate: (ports) => ports.gate, request, service } so the server owns gate attachment and identity changes can never go stale.

    The ports argument includes app ports plus ports provided during server startup.

    Server hooks that wrap every registered route.

    instrumentation?: ServerInstrumentationOptions<Ctx> | false

    Server-owned request instrumentation.

    The server resolves a request ID and W3C trace context for every request before user hooks and context creation, writes x-request-id and traceparent response headers, and records request and error events into the resolved provider instrumentation port (ports.instrumentation, then ports.devtools) when one is installed.

    Pass false to disable headers and event recording. Context factories still receive requestId and trace arguments.

    Optional pure startup check for app workflow registrations.

    Runtime integrity compares app-declared workflow artifacts against the registries passed to runtime entrypoints. It performs no filesystem, provider, database, network, worker, or background-loop work, so it is safe to run during serverless cold starts.

    mapUnhandledError?: ServerUnhandledErrorMapper<Ctx>

    Global mapper for unexpected errors not handled by app error catalogs.

    onCaughtError?: ServerCaughtErrorHook<Ctx>

    Global caught-error observer.

    onUnboundPorts?: "error" | "warn" | "ignore"

    How to handle ports that are still unbound after all providers have started.

    Ports declared as deferred in definePorts(...) boot as throwing placeholders until a provider contributes them. The default "error" fails startup and lists the unbound port keys. Apps that bind every port directly are unaffected.

    "error"
    
    ports: Ports

    App-owned ports available to context creation, hooks, and handlers.

    providerConfig?: Record<string, unknown>

    Provider config overrides keyed by provider name.

    providerEnv?: Record<string, string | undefined>

    Runtime env used by providers. Defaults to process.env.

    providers?: Providers

    Providers installed during server startup.

    Provider ports are merged into ports before request handling and are stopped in reverse setup order when server.stop() runs.

    requestBody?: RequestBodyOptions

    Request body parsing limits for JSON/text contract routes.

    routes?: Routes

    Route list to register up front.

    validateResponses?: boolean

    Whether route-owned responses are validated against the contract's declared statuses and response schemas before they are sent.

    Disable this to trade response guarantees for throughput, mirroring the client-side validateResponses option.

    true