0.0.4 • Published 10 years ago

multiget v0.0.4

Weekly downloads
17
License
-
Repository
github
Last release
10 years ago

multiget

multiget — express middleware that allow aggregate few api request into one response

Installation

npm install multiget

API

###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/api2

and 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