Skip to content

toHttpResponse

toHttpResponse(error): HttpResponse

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

The HTTP answer for a RateLimitExceededError: 429 Too Many Requests with a Retry-After header. Framework filters and Express handlers reply with it. The body never carries the bucket key, which holds the tenant and the caller.

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);
});