Skip to content

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 27 Sep 06:07
· 62 commits to main since this release
89956f3

Every failure reaches the application's onError hooks — a 404, a 405 and a rate limit's refusal included — so one hook sets the format of every error, and errors in @tetsujs/openapi describes that format in the document.

Breaking changes

  • @tetsujs/core: 404 and 405 reach the application's onError hooks as an HttpError, like every other failure. An onError hook that answers every error — or logs each one — now sees unmatched paths and methods too. An application without onError hooks answers them as before, with the same response and at the same cost.
  • @tetsujs/rate-limit: a refusal is a thrown HttpError with retryAfter in its body, and reaches the application's onError hooks. It used to be a returned Response that onError never saw.

Added

  • @tetsujs/openapi: errors in openapi() and docs() — an error format of the application's own, for the document to describe the framework's failures, the hooks' refusals and the routes' own envelopes in it. schema describes one failure from its status, code, message and fields; discriminator names the top-level field with the code; code reads the code from a route's schema, for a format that nests it. A definition that differs from the kept one is now compared at every depth, so a nested format's missing field is reported by its path.

Changed

  • @tetsujs/core: the error path is synchronous until something on it waits, as the success path is. Every failure the onError hooks see takes it — a thrown HttpError, a validation failure, a refusal — and each now costs 110–170 ns less, a refusal through the pipeline 776 ns where it was 880.

Moving from 0.4

An onError hook on the application now receives 404, 405 and a rate limit's 429 as an HttpError. A hook that maps only errors it knows — returning nothing for the rest — needs no change: the default envelope answers as before. A hook that answers or logs every error should check error.status if those three are not meant for it.

Full Changelog: v0.4.2...v0.5.0