v1.7.0
·
26 commits
to develop
since this release
Immutable
release. Only release title and notes can be modified.
What's Changed
This release adds the suppressDetail option to HttpExceptionFilter to prevent internal error messages from leaking to clients (done in #37), and improves runtime performance by eliminating repeated URL construction on the exception hot path (done in #38).
Features
suppressDetailoption — passtrueto omitdetailon every response, or a callback for conditional suppression (e.g. only on 5xx errors). When using the module, override theSUPPRESS_DETAIL_KEYDI provider. A throwing callback is swallowed and treated as "do not suppress" so it can never crash the exception filter:
// Always suppress
new HttpExceptionFilter(app.get(HttpAdapterHost), '', undefined, true)
// Suppress selectively
new HttpExceptionFilter(app.get(HttpAdapterHost), '', undefined, ({ status }) => status >= 500)
// Via module
{ provide: SUPPRESS_DETAIL_KEY, useValue: ({ status }) => status >= 500 }SuppressDetailtype — exported fromnest-problem-details-filter. Acceptsboolean | ((ctx: SuppressDetailContext) => boolean).SuppressDetailContext— exported context shape (status,type,exception) passed to the callback.SUPPRESS_DETAIL_KEY— exported DI token for module-level configuration.
Performance
- Precomputed type URI cache —
HttpExceptionFilternow resolves alldefaultHttpErrorsentries againstbaseUrionce at construction time and stores them in aMap<number, string>. Thecatch()hot path performs a singleMap.get(status)instead of twonew URL(...)allocations for the common case (native Nest exceptions and plainHttpExceptionwith no caller-suppliedtype). Exceptions with an explicittype(e.g.ProblemDetailsException) continue to resolve live and behave identically.
Full Changelog: v1.6.0...v1.7.0