Beignet API reference
    Preparing search index...

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

    Options for creating a Beignet server instance.

    type CreateServerOptions<
        Ctx,
        Ports extends AnyPorts,
        Routes extends
            readonly RouteDef<Ctx, any>[] = readonly RouteDef<Ctx, any>[],
        Providers extends
            readonly ServiceProvider<unknown, StandardSchemaV1<any, any>, AnyPorts>[] = readonly [
            ,
        ],
    > = {
        createContext: (
            args: {
                contract?: HttpContractConfig;
                ports: Ports & ProvidedPortsOfList<Providers>;
                req: HttpRequestLike;
            },
        ) => Ctx
        | Promise<Ctx>;
        hooks?: ServerHook<Ctx, Ports & ProvidedPortsOfList<Providers>>[];
        mapUnhandledError?: ServerUnhandledErrorMapper<Ctx>;
        onCaughtError?: ServerCaughtErrorHook<Ctx>;
        ports: Ports;
        providerConfig?: Record<string, unknown>;
        providerEnv?: Record<string, string | undefined>;
        providers?: Providers;
        routes?: Routes;
    }

    Type Parameters

    Index

    Properties

    createContext: (
        args: {
            contract?: HttpContractConfig;
            ports: Ports & ProvidedPortsOfList<Providers>;
            req: HttpRequestLike;
        },
    ) => Ctx
    | Promise<Ctx>

    Create request context after a route is matched.

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

    Server hooks that wrap every registered route.

    mapUnhandledError?: ServerUnhandledErrorMapper<Ctx>

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

    onCaughtError?: ServerCaughtErrorHook<Ctx>

    Global caught-error observer.

    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.

    routes?: Routes

    Route list to register up front.