express-rpc
v0.0.4
Published
Promise-based rpc middleware generator
Downloads
14
Maintainers
Readme
express-rpc
Transform a promise-based module into an express middleware.
var myPromiseBaseModule = require('my-promise-based-module');
var rpc = require('express-rpc')
var simpleJSON = rpc({
extract: (req) => ({method: req.path.slice(1), args: JSON.parse(req.body)}),
success: (res, retVal) => res.status(200).send(retVal),
error: (res, status, err) => res.status(status).send(err.stack)
});
var rpcMiddleware = simpleJSON(myPromiseBaseModule);
// ...
app.use(rpcMiddleware);
// Profit
install
with npm do:
npm install express-rpc
license
MIT