Skip to content
TypeWire

@tahanabavi/typewire-nestjs

documents v0.1.1

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.

Honoring the contract's auth flag

The bound endpoint is available to guards via getContractEndpoint():

ts
import { getContractEndpoint } from "@tahanabavi/typewire-nestjs";

@Injectable()
export class ContractAuthGuard implements CanActivate {
canActivate(context: ExecutionContext): boolean {
const endpoint = getContractEndpoint(context);
if (!endpoint?.auth) return true; // public per contract
return this.validateBearerToken(context); // your auth logic
}
}

// app.module.ts
providers: [{ provide: APP_GUARD, useClass: ContractAuthGuard }]