https://github.com/mostlyjs/mostly-poplarjs
MostlyJS microservice integration with poplarjs
https://github.com/mostlyjs/mostly-poplarjs
microservice poplarjs
Last synced: 9 months ago
JSON representation
MostlyJS microservice integration with poplarjs
- Host: GitHub
- URL: https://github.com/mostlyjs/mostly-poplarjs
- Owner: MostlyJS
- License: mit
- Created: 2017-05-01T15:27:02.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T08:21:41.000Z (over 7 years ago)
- Last Synced: 2025-02-10T11:18:26.952Z (about 1 year ago)
- Topics: microservice, poplarjs
- Language: JavaScript
- Homepage:
- Size: 137 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
MostlyJS with Poplarjs
======================
[](https://travis-ci.org/mostlyjs/mostly-poplarjs)
This module provides quick steps to create [MostlyJS](https://github.com/MostlyJS/mostly-node) microservices with [Poplarjs](https://github.com/poplarjs/poplar).
# Usage
## Installation
```bash
npm install mostly-poplarjs
```
## Quick Example
Convert your Poplarjs APIs into microservices is easy enough.
Your existing Poplarjs code
```javascript
// dummy_api.js
const ApiBuilder = poplar.ApiBuilder;
var DummyApi = new ApiBuilder('dummies');
DummyApi.define('info', {...});
....
module.exports = DummyApi;
```
Wrapping it as standalone server
```javascript
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](https://github.com/MostlyJS/mostly-poplarjs-rest)
# License
MIT