microa
Framework for easily building responsive microservices. 🔬
Introduction
Framework works only with Node >= 8.5 and flag --experimental-modules
.
Install
$ npm i microa -S
Tests
$ npm test
Usage
Microservice natively can accept requests via http & sockets.
Backend:
; ; ;
Frontend:
// Create connect to the microserviceconst socket = ; // Send an event via promisified emit methodconst response = await socket;
// Send an event via axiosconst data = await axios;
Methods
Import all needed methods.
;
.createModels(models)
Create models for context. Every class constuctor accepts one argument ctx
.
;
After initializing models, instances will passed in ctx.models
.
;
.createRoute(prefix, routes)
Create routes. Paths will transform for socket.io
& http
automatically. Be careful, http
requests work only via POST
method.
socket.io
⇒books:get-all
http
⇒/books/get/all
;
.createApp(options)
Start listening app.
;
License
MIT.