Skip to content

skunight/nestjs-rabbitmq

Repository files navigation

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!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published