NestJS integration for @amqp-contract/client
npm install @amqp-contract/client-nestjsNestJS integration for @amqp-contract/client. Type-safe AMQP message publishing with automatic lifecycle management.





``bash`
pnpm add @amqp-contract/client-nestjs @amqp-contract/client @amqp-contract/contract amqplib
`typescript
import { Injectable, Module } from "@nestjs/common";
import { AmqpClientModule, AmqpClientService } from "@amqp-contract/client-nestjs";
import { contract } from "./contract";
@Module({
imports: [
AmqpClientModule.forRoot({
contract,
urls: ["amqp://localhost"],
}),
],
})
export class AppModule {}
@Injectable()
export class OrderService {
constructor(private readonly client: AmqpClientService
async createOrder(orderId: string, amount: number) {
await this.client.publish("orderCreated", { orderId, amount }).resultToPromise();
}
}
``
The client automatically connects when the module initializes and cleans up on shutdown.
š Read the full documentation ā
MIT