Releases: seek-oss/koala
v7.0.4
v7.1.0-beta.1
v7.0.3
v7.0.2
v7.0.1
v7.0.0
7.0.0 (2023-08-25)
BREAKING CHANGES
ErrorMiddleware: Only respect certain err.status
es (#199) (591fb75)
Some HTTP clients throw errors with a status
property to indicate the status code of the HTTP response. If such an error was not handled by a middleware or controller further up the chain, ErrorMiddleware.handle
would previously pick up the error and reflect its status code back to your client.
Most of the time, this is not what you want. For example, if your server depends on an upstream service-to-service endpoint and it starts to respond with HTTP 401s, that may imply that your server is not appropriately authenticated and is at fault, and should default to a HTTP 500. This is now the default behaviour of ErrorMiddleware.handle
.
If you want to throw an error that ErrorMiddleware.handle
will pick up to modify your response status code, you are now limited to three options:
-
Use
http-errors
import createError from 'http-errors'; const controller = () => { throw new createError.ImATeapot(); };
-
Use
ctx.throw
const controller = (ctx) => { ctx.throw(418, 'Badness!'); };
-
Include
isJsonResponse
andstatus
properties on your errorclass MyCustomError extends Error { constructor( message: string, public isJsonResponse: boolean, public status: number, ) { super(message); this.isJsonResponse = isJsonResponse; this.status = status; } } const controller = () => { throw new MyCustomError('Badness!', [secure], 418); };
v6.0.0
6.0.0 (2022-05-31)
Features
- TracingHeaders: Use
crypto.randomUUID
(#157) (1db0bcb)
BREAKING CHANGES
- TracingHeaders: Koala has switched generation of V4 UUID request IDs from the third-party
uuid
module to the built-innode:crypto
module. The minimum supported Node.js version is now 14.17.0.