mongo-microservice
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

mongo-microservice

Opinionated Node microservice/worker base intended to utilized MongoDB + RabbitMQ

Usage

let Service = require('mongo-microservice');
const QUEUE_NAME = 'example';
class ExampleService extends Service {

  constructor (config) {
    super(process.env.mongoUri, process.env.rabbitUri);
    this.addQueues([{name: QUEUE_NAME, handler: this._handleExample}]);
    this.mongoose = this.getMongooseReference();
  }

  _handleExample (payload, ack) {
    console.log(payload);
    ack();
  }

  start () {
    super.start();

    this.publish(QUEUE_NAME, 'Hello World');
}

module.exports = ExampleService;

API

  • addQueues

Events

Readme

Keywords

none

Package Sidebar

Install

npm i mongo-microservice

Weekly Downloads

9

Version

0.1.5

License

MIT

Unpacked Size

23.6 kB

Total Files

21

Last publish

Collaborators

  • asilluron