batch-api-merger
A module that gets a single REST api request containing multiple REST api endpoints, gathers the reply of each one and sends back to the client a complete answer.
Last updated 3 years ago by diamantatos .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install batch-api-merger 
SYNC missed versions from official npm registry.

batch-api-merger

Build Statuscodecov

Batch Api Merger

A module that gets a single REST api request containing multiple REST api endpoints, gathers the reply of each one and sends back to the client a complete answer.

Server Example

app = require('batch-api-merger')('http://localhost:3000/', '/api/resources');

app.get('/api/users', function (req, res, next) {
  res.send([{username: 'hello', name: 'world'},{username: 'john', name: 'doe'}]);
})

app.get('/api/customers/23', function (req, res,next) {
  res.send({customer: 'hello', name: 'world'});
})

app.get('/api/countries', function (req, res,next) {
  res.send([{country: 'Greece', name: 'Hellas'},{country: 'Denmark', name: 'Danmark'}]);
})

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})

Http Call Example

http://localhost:3000/api/resources?users=api/users&customer=api/customers/23&countries=api/countries

will give back

{"users":[{"username":"hello","name":"world"},{"username":"john","name":"doe"}],"customer":{"customer":"hello","name":"world"},"countries":[{"country":"Greece","name":"Hellas"},{"country":"Denmark","name":"Danmark"}]}

License

MIT

Current Tags

  • 1.1.4                                ...           latest (3 years ago)

8 Versions

  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 4
Last Day 0
Last Week 1
Last Month 4
Dependencies (3)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |