Skip to content

HandlerResult

type HandlerResult = FlareResponse | Response | AsyncIterable<unknown> | object | null | undefined

All values a route handler is permitted to return.

At the transport layer, any non-ResponseLike value is normalised to a FlareResponse by normalizeHandlerResult before being written to the client. Ordering of the union matches the runtime dispatch table:

  1. FlareResponse / Response: passed through unchanged.
  2. AsyncIterable<unknown>: wrapped in a chunked streaming FlareResponse.
  3. object: either a model instance (serialised via its compiled serializer) or a plain object/array (serialised with JSON.stringify).
  4. null / undefined: throws an internal error.

Any other value (primitive, function, symbol, etc.) throws an unsupported-type internal error.

Learn: Overview

Last updated: