@zedtech/zedkit-nest
Return uniform error bodies
A global exception filter that returns the same error body for all failures.
At a glance
- Who: API developers who want one error shape for every failure.
- What: A global exception filter that returns the same error body for all failures. Subclass and override
toStatusBody,unknownBodyParseError, orformatBodyto map domain errors without rewriting the filter. - Use when: As the last-resort error mapper in front of API clients.
- Avoid when: For domain validation errors with field detail — return those from the handler instead.
- See also: Bootstrap a Nest app, Start a safe NestJS API
Install
pnpm add @zedtech/zedkit-nestLatest: 1.1.1 (via changesets).
Example
import { AllExceptionsFilter, type ErrorBody } from "@zedtech/zedkit-nest";
class AppFilter extends AllExceptionsFilter {
protected override formatBody(body: ErrorBody) {
return { code: body.code, message: body.message };
}
}Wraps: (none)
Keep request logs compact and silence chosen paths
Pass compact req/res serializers and a quiet-path log level through the bootstrap logger options.
Start a safe NestJS API
End-to-end tutorial: boot with `createNestApp`, validate DTOs, return prefixed ids, and exercise the documented error shape with `curl`.