npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

express-bunch-middleware

1.0.4 • Public • Published

express-bunch-middleware

Express middleware to combine multiple API requests into one.

Build Status Coverage Status

Usage

const express = require('express');
const bunch = require('express-bunch-middleware');
const app = express();
 
app.use('/resources', bunch);
 
app.get('/api/users', (req, res) => {
    res.json([{name: 'John', surname: 'Doe'}]);
});
 
app.get('/api/countries/:id', (req, res) => {
    setTimeout(() => {
        res.json({name: 'United States of America', countryCode: 'USA'});
    }, 30)
});
 
app.listen(3000);

Description

API call like:

GET /resources?users=/api/users&country=/api/countries/23

will responds with:

{
    "users": [{
        "name": "John",
        "surname": "Doe"
    }],
    "countries": [{
        "name": "United States of America",
        "countryCode": "USA"
    }]
}

License

MIT

install

npm i express-bunch-middleware

Downloadsweekly downloads

5

version

1.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability