0.0.4 • Published 12 years ago
multiget v0.0.4
multiget
multiget — express middleware that allow aggregate few api request into one response
Installation
npm install multigetAPI
###multiget(apiHost) — creates middleware
Example
var express = require('express'),
multiget = require('multiget'),
app = express();
app.use(multiget('http://localhost:4000'));
app.listen(3000);Response format
Calling GET http://localhost:3000/api/multi?key1=api1&key2=api2 for example above will made following requests:
GET http://localhost:4000/api1
GET http://localhost:4000/api2and will combine responces into one:
{
key1: {
result: /*api responce*/,
error: /*error message*/
},
key2: {
result: /*api responce*/,
error: /*error message*/
}
}if API will set content-type to application/json the middleware will trying to parse response
fields error and result are mutually exclusive
Tests
npm test