OptionalafterObserves the final response after send preparation.
OptionalbeforeRuns after request parsing, context creation, and route hook resolution.
OptionalbeforeRuns before the response is returned. Native web Response results get a
headers-only view with native: true.
OptionalmapMaps unexpected errors to responses.
OptionalnameOptional name used in diagnostics and devtools.
OptionalonObserves framework-caught errors.
OptionalonRuns after route matching and before body/query/header parsing.
OptionalvalidateValidates 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.
Server lifecycle hook collection.
Hooks run in the order they are registered within each server-hook phase.
onRequestcan short-circuit before context creation; route hooks resolve route-scoped context before serverbeforeHandle;beforeHandlecan replace context or short-circuit;beforeSendcan replace the outgoing response, and route-owned replacements are contract-validated before send;afterSendobserves the final response.