UNPKG

regard

Version:

Sugar-interface to access multiple data sources.

45 lines (37 loc) 1.22 kB
var Regard = require('.'); var regard = Regard('fs', 'http', 'mongodb', 'rabbitmq'); regard .$('mb', 'http://mockbin.com') .$('root', __dirname) .$('data', 'mongodb://localhost/mydb') .$('broker', 'amqp://admin:password@172.17.0.24:5672') .mb.$('request', 'request') .root.$('sample', 'sample.json') .data.$('usr', 'users') .broker.$('test', 'hello'); /*/ regard.broker.test.produce({foo:'bar'}) .then(function (ok) { console.log(ok); }) .catch(function (err) { console.error(err.stack); }); /*/ regard.broker.test('consume', function (x) { console.log('cp', x.content.toString()); }) //.then(function (m) { console.log(m.content.toString()); return regard.broker.test.consume(); }) .catch(function (err) { console.error(err.stack); }); /* regard.data('insert', 'users', {foo:'bar'}) .then(function () { return regard.data('find', 'users', {}); }) .then(function (x) { console.log(x); process.exit(); }) .catch(function (err) { console.error(err.stack); }); //*/ /*/ #3 Execute a request, write and print the result regard.mb.request.post() .then(function (res) { return regard.root.sample('write', res.body); }) .then(console.log); //*/