So instead of:
app.use(getUser);
app.use(getSiteList);
app.use(getCurrentSite);
app.use(getSubscription);
… we could do something like this:
function parallel(middlewares) {
return function (req, res, next) {
async.each(middlewares, function (mw, cb) {
mw(req, res, cb);
}, next);
};
}
app.use(parallel([
getUser,
getSiteList,
getCurrentSite,
getSubscription
]));
Không có nhận xét nào:
Đăng nhận xét