Skip to content
TypeWire

@tahanabavi/typewire-nestjs

v4.0.0

NestJS integration for the TypeWire ecosystem — serve one set of Zod contracts over every wire your client speaks: REST/HTTP, gRPC (Connect JSON), GraphQL and typesocket WebSocket gateways, with request/response validation on all of them.

Global configuration

The decorators work with zero setup. Import the module to change defaults app-wide:

ts
@Module({
imports: [
TypeFetchModule.forRoot({
validateRequest: true, // default
validateResponse: true, // default
coerce: true, // default
exposeResponseErrors: process.env.NODE_ENV !== 'production',
}),
],
})
export class AppModule {}

Every option can also be overridden per endpoint: @TypeFetchEndpoint(endpoint, { validateResponse: false }).

Flat (non-structured) contracts

A request schema that isn't shaped as { path, query, body, headers } is "flat" — the client sends the whole input as the JSON body, and the server validates req.body against the whole schema. Both styles work with both decorators.