1.0.9 โ€ข Published 6 months ago

@chinmay20409/nest-js-bull-helper v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

๐Ÿชต NestJS BullMQ Logger Helper

A dynamic NestJS module to enable automatic log publishing to BullMQ queues and real-time WebSocket log streaming (consumer WIP).

๐Ÿ“ฆ Installation

npm install @chinmay20409/nest-js-bull-helper

Make sure you have Redis running locally or remotely.


๐Ÿš€ Usage in a NestJS Project

1. Import the LoggerModule in your AppModule:

import { LoggerModule } from '@chinmay20409/nest-js-bull-helper';

@Module({
  imports: [
    LoggerModule.register({
      connection: {
        host: process.env.REDIS_HOST || 'localhost',
        port: parseInt(process.env.REDIS_PORT || '6379'),
      },
      queueName: 'order-logs1',
      projectId: 'capp',
    }),
  ],
})
export class AppModule {}

2. Inject and use CustomLoggerService anywhere:

import { Injectable } from '@nestjs/common';
import { CustomLoggerService } from '@chinmay20409/nest-js-bull-helper';

@Injectable()
export class SomeService {
  constructor(private readonly logger: CustomLoggerService) {}

  someMethod() {
    this.logger.error('Something went wrong', 'stack trace', 'SomeService');
    this.logger.warn('Just a warning', 'SomeService');
  }
}

๐Ÿ›  Features

  • โœ… Easy setup with LoggerModule.register({...})
  • โœ… Queue name, project ID, and Redis credentials configurable
  • โœ… Logs are automatically pushed to the queue โ€” no extra code required
  • ๐Ÿงฉ (Coming Soon) Real-time WebSocket dashboard (via ConsumerLoggerModule)

๐Ÿงช Local Development

To build locally:

npm run build

To update version (make sure git is clean):

npm version patch
npm publish --access public

๐Ÿค Contribution

Feel free to open PRs or issues if you'd like to help improve the module.


Let me know if you want a separate README section for the ConsumerLoggerModule too.