Skip to content

toHttpResponse

toHttpResponse(error): HttpResponse

Defined in: packages/pipeline-rate-limit/src/http.ts:25

The HTTP answer for a RateLimitExceededError: 429 Too Many Requests with a Retry-After header. Framework filters and Express handlers reply with it.

RateLimitExceededError

HttpResponse

app.use((error, _req, res, next) => {
if (!(error instanceof RateLimitExceededError)) return next(error);
const { status, body, headers } = toHttpResponse(error);
res.status(status).set(headers).json(body);
});