const express = require('express');
const app = express();
const auth = (rules) => (req, res, next) => {
setTimeout(() => {
next(new Error('Validation fail'));
}, 1000)
}
app.get('/', (req, res, next) => {
console.log('-------')
console.log('1');
next()
})
app.get('/', auth(['admin']), (req, res, next) => {
console.log('2')
next();
})
app.get('/', (req, res, next) => {
console.log('3')
next()
})
app.use((err, req, res, next) => {
console.log(err)
res.send('Server / User error');
})
app.listen(3000);