Skip to content

OleksiiKukuruza/express-bunch-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published