Skip to main content

Function: StreamingBody()

StreamingBody(): (target, propertyKey?, descriptor?) => void

Defined in: service-core/src/decorators/RouteDecorators.ts:488

Indicates that the decorated route handler wants the raw request body exposed as a stream (req.bodyStream, a Node Readable — see the @BodyStream() argument decorator) instead of having it fully buffered into memory as req.body/req.rawBody before the handler runs. Intended for large uploads (e.g. multi-GB PST/mbox mailbox imports) where buffering the entire body first would defeat the point of streaming it straight to disk or another sink.

Opting in disables the framework's default request-body buffering AND its maxBodySize 413 rejection for this route entirely — the handler alone is responsible for consuming req.bodyStream and for enforcing whatever size limit it wants (e.g. counting bytes as they arrive and destroying the stream if a limit is exceeded). Backpressure is still handled by the framework: a slow consumer naturally throttles how fast bytes are read off the connection rather than buffering unbounded data in memory.

A route that relies on req.body/req.rawBody being populated — a @Validate function, a before/after function, or the decorated handler's own implicit body argument — must NOT be combined with this decorator; those all read undefined on a streaming route.

Can be applied to a route class (every route in the class streams) or an individual route handler method (only that endpoint streams), the same class/method pairing rules as @RateLimit/ @RequiresElevation apply.

Returns​

(target, propertyKey?, descriptor?) => void