Beignet API reference
    Preparing search index...

    Interface RouteHook<Ctx, AddedCtx>

    Hook that runs only for the route or route group where it is attached.

    Route hooks are for scoped policy and context enrichment such as authentication, tenant resolution, feature gates, and idempotency. They add fields to the handler context instead of replacing the app context.

    Hook additions must not include gate: the server re-attaches the gate declared by the context blueprint after every hook, so identity changes are picked up automatically.

    interface RouteHook<
        Ctx,
        AddedCtx extends object & { gate?: never } = Record<string, never>,
    > {
        name?: string;
        resolve: (args: RouteHookArgs<Ctx>) => MaybePromise<AddedCtx | undefined>;
    }

    Type Parameters

    • Ctx
    • AddedCtx extends object & { gate?: never } = Record<string, never>
    Index
    name?: string

    Optional name used in diagnostics and devtools.

    resolve: (args: RouteHookArgs<Ctx>) => MaybePromise<AddedCtx | undefined>

    Resolve additional context for this route or throw to stop handling.