@rtorcato/api-timeout-express v0.1.0
Functions
timeoutMiddleware()
timeoutMiddleware(
__namedParameters):RequestHandler
Defined in: index.ts:16
Express middleware that fails a request with 503 if the response isn't sent
within ms. Responds with the standard error envelope
{ error: 'ServiceUnavailableError', code: 'service_unavailable', message }
from @rtorcato/api-errors. If the handler responds first, the timer is
cleared and nothing extra is sent.
ponytail: on timeout we send 503 and stop; a slow handler that later tries to
write will hit Express's "headers already sent" — guard late writes with
res.headersSent in long handlers.
Parameters
__namedParameters
TimeoutOptions
Returns
RequestHandler