Home

Awesome

MostlyJS with Poplarjs

Build Status

This module provides quick steps to create MostlyJS microservices with Poplarjs.

Usage

Installation

npm install mostly-poplarjs

Quick Example

Convert your Poplarjs APIs into microservices is easy enough.

Your existing Poplarjs code

// dummy_api.js
const ApiBuilder = poplar.ApiBuilder;
var DummyApi = new ApiBuilder('dummies');
DummyApi.define('info', {...});
....
module.exports = DummyApi;

Wrapping it as standalone server

const nats = require('nats');
const mostly = require('mostly-node');
const poplar = require('mostly-poplarjs');
const dummyApi = require('./dummy_api');

const trans = new mostly(nats.connect());
trans.ready(() => {
  var app = poplar.create(trans)
    .use(dummyApi)
    .handler();
});

That's all, the service will register itself with NATS and can be called remotely.

RESTful Gateway

To expose the service as RESTful api, you need only setup a simple express gateway server using mostly-poplarjs-rest

License

MIT