UNDER CONSTRUCTION
This library is under construction, so use at your own risk
Why microsia?
Microsia is an lightweight microservices server with simple, familiar syntax that was inspired by koa and express, allow you to create transport layer for microservices as quick as possible.
Currently, microsia is building around nats as central messaging system. Microsia also has local pubsub system, that allow services on same server communicate with each other fastest without remote messaging system (nats).
Concept:
Usages:
Install package
npm install --save microsia
# OR
yarn add microsia
Sample service services/bar.js
:
const broker = const service = service service // Call to other service using current context// Metadata (requestId,...) will be past to other service, tooservice // Call directly from service will create new contextservice
Run group services with service runner:
const loadServices = // Service pathconst services = 'services/foo.js' 'services/bar.js'const options = transporter: name: 'nats' options: servers: 'nats://demo.nats.io:4222' timeout: 3000 pingInterval: 120000 reconnect: true reconnectTimeWait: 2000 maxReconnectAttempts: 10 maxRequestRetryAttempts: 3
You also can run only one service directly by node
,
just pass config to broker()
and then run node services/bar.js
:
const broker = const service = ...
Please see example code in example
folder for more information.
Run example code:
Internal Services using runner:
cd example
node index.js
ApiGateway using broker directly and using express as http server:
cd example/gateway
yarn
node index.js
Make request to ApiGateway
curl -i -H "Accept: application/json" "http://localhost:3000/api/bar"
TODO:
- Api Gateway
- Group route
- Middleware with route
- Streaming file
- Circuit Breaker (inside broker)
- Logger
- Nats authrorize
- Serialize (protobuf, ...)
- Polish code
- Unit test & code coverage
- Benchmark
- Optimize
- Improve documentation & example
- Kafka transporter
- Multi transporter in one broker (consider later)