Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 1.13 KB

README.md

File metadata and controls

57 lines (48 loc) · 1.13 KB

Nestjs Rabbitmq

Rabbitmq component for NestJs.

Installation

Yarn

yarn add nestjs-rabbitmq

NPM

npm install nestjs-rabbitmq --save

Getting Started

Let's import the RabbitMqModule in app.module.ts

import { Module } from '@nestjs/common';
import { RabbitMqModule} from 'nestjs-rabbitmq'

@Module({
    imports: [
        RabbitMqModule.forRoot(options)
    ],
})
export class AppModule {}

With Async

import { Module } from '@nestjs/common';
import { RabbitMqModule} from 'nestjs-rabbitmq'

@Module({
    imports: [
        RabbitMqModule.forRootAsync({
            useFactory: (configService: ConfigService) => configService.get('rabbitmq'),         // or use async method
            //useFactory: async (configService: ConfigService) => configService.get('rabbitmq'),
            inject:[ConfigService]
        }),
    ],
})
export class AppModule {}

Options

interface RabbitMqModuleOptions {
  user?: string,    //Default guest
  passwd?: string,  //Default guest
  host?: string,    //Default localhost
  port?: number     //Default 5672
}

That's it!