conducto
Node.js framework, REST and realtime
Server
var conducto = require('conducto');
var server = new conducto.Server();
server.use(function(req, res, next)
if (req.method !== 'sum')
return next();
if (!req.payload || !Array.isArray(req.payload))
return res('Payload must be an array.');
var sum = 0;
for (var i = 0; i < payload.length; i++) {
sum += payload[i];
}
res(null, sum);
});
server.listen(3000);
Client
var client = new conducto.Client();
client.open({secure: false, hostname: localhost, port: 3000});
client.on('open', function() {
client.send('sum', 'foo', function(err, res) {
console.log(err || res);
});
client.send('sum', [0, 1, 2, 3], function(err, res) {
console.log(err || res);
});
});