1.0.9 • Published 6 years ago
mostly-poplarjs v1.0.9
MostlyJS with Poplarjs
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
import nats from 'nats';
import mostly from 'mostly-node';
import poplar from 'mostly-poplarjs';
import dummyApi from './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