express-message
Express Message Queue based async message routing library
Install
Stable Release (1.2.x
)
$ npm install express-message --save
Simple Usage
const app = ; /* Validate */app; app; const messages = "method": "add" "params": 23 42 "jsonrpc": "2.0" "method": "subtract" "params": 5 3 "jsonrpc": "2.0" "method": "add" "params": 18 8; messages; // because of library works asynchronously;
Handler
For a complex project you can create separate handlers then use them from app.
// ***// main.jsconst app = ;const customHandler = ; app;// or this is also correct app.handle({}, customHandler); // ***// customHandler.jsconst customHandler = ;customHandler; moduleexports = customHandler;
Matching
express-message uses jpv as a matcher.
Here are some examples.
Regular Expression app.handle( { jsonrpc : /[12]+\.[\d]/ }
Native Types { jsonrpc : "2.0", params : "(object)", timestamp : "(number))" }
Custom Types { jsonrpc : [float], email : "[email]", }
Logical negation : { jsonrpc : !(boolean) }
For more information please check JPV official npm repository
Queue Integration
Kafka implementation
const app = ; // here are your hendlersapp; // ... // your kafka consumerconsumer;
Redis implementation
const app = ; // here are your hendlersapp; // ... // your redis subscribersubscriber;