microset
Lightweight microservices framework for NodeJS. Production code does not include any node_module
dependencies.
Key Features
- Lighweight - zero
node_module
dependencies - Expose services API over HTTP (JSON-RPC)
- Client for frontend apps
- Service Registry
- Log management
- Configuration management
- Services running in separate processes
- Bundled set of services
- Directory
- Echo
- HTTP Server
- JSON-RPC Gateway
- JSON-RPC Client
- JSON Storage
- Static Content
Installation
Install microset from npm repository:
$ npm install microset --save
Usage Example
Create your service implementation in MyService.js
file:
const microset = ; // Your service implementation.// It must extends microset.Service class.Service async { // expose method to access them externally this; } // your logic comes here async { thislogger; return hello: "world"; }moduleexports = MyService;
Create main entry point for your app index.js
:
const microset = ; // create the container and register your service.let services = ;services; // start JSON-RPC gateway// Your service will be available over JSON-RPC at// http://localhost:8080/api/MyService// Web client that you can use for tests is here:// http://localhost:8080/clientmicrosetbuild;
Run microset and your service:
$ node myservice.js 23:40:04 | MyService | INFO | Initialising MyService service...23:40:04 | HttpServerService | INFO | Initialising HttpServerService service...23:40:04 | JsonRpcGatewayService | INFO | Initialising JsonRpcGatewayService service...23:40:04 | JsonRpcClientService | INFO | Initialising JsonRpcClientService service...23:40:04 | MyService | INFO | Service MyService initialised.23:40:04 | MyService | INFO | Exposing method 23:40:04 | MyService | INFO | Service ready23:40:04 | JsonRpcGatewayService | INFO | Service JsonRpcGatewayService initialised.23:40:04 | JsonRpcGatewayService | INFO | Exposing method 23:40:04 | JsonRpcGatewayService | INFO | Service ready23:40:04 | JsonRpcClientService | INFO | Service JsonRpcClientService initialised.23:40:04 | JsonRpcClientService | INFO | Exposing method 23:40:04 | JsonRpcClientService | INFO | Exposing method 23:40:04 | JsonRpcClientService | INFO | Service ready23:40:04 | HttpServerService | INFO | HTTP server started: http://localhost:808023:40:04 | HttpServerService | INFO | Service HttpServerService initialised.23:40:04 | HttpServerService | INFO | Exposing method 23:40:04 | HttpServerService | INFO | Service ready
Visit http://localhost:8080/client, fill the form:
- Gateway URL: /api
- Service: MyService
- Method: helloWorld
- Parameters: []
and press submit to see results.
More examples
For more examples see example folder.