Beignet API reference
    Preparing search index...

    Interface ServerHook<Ctx, Ports>

    Server lifecycle hook collection.

    Hooks run in the order they are registered within each server-hook phase. onRequest can short-circuit before context creation; route hooks resolve route-scoped context before server beforeHandle; beforeHandle can replace context or short-circuit; beforeSend can replace the outgoing response, and route-owned replacements are contract-validated before send; afterSend observes the final response.

    Type Parameters

    Index

    Observes the final response after send preparation.

    Runs after request parsing, context creation, and route hook resolution.

    Runs before the response is returned. Native web Response results get a headers-only view with native: true.

    Maps unexpected errors to responses.

    name?: string

    Optional name used in diagnostics and devtools.

    Observes framework-caught errors.

    Runs after route matching and before body/query/header parsing.

    validate?: (args: { contracts: readonly HttpContractConfig[] }) => void

    Validates the hook configuration against the registered contracts.

    Invoked once at startup, right after createServer(...) collects the contracts from the routes option and before provider setup. Throw to fail startup instead of degrading silently at request time. Contracts registered later through server.route(...) are not seen here, so hooks that need full coverage should keep a runtime check as a backstop.