//not from real code
makeApiCall(requireLogin, apiMiddleware) {
if (requireLogin) {
return [ authMiddleware, apiMiddleware ];
}
else {
return [ apiMiddleware ];
}
}
app.post('/api/foo', makeApiCall(true, (req, res) => {}); //this one requires auth
app.get('/api/foo', makeApiCall(false, (req, res) => {});