You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

15 lines
408 B

// handle time out errors
function middleware(err, req, res, next) {
res.header('Cache-Control','no-cache');
var error = err.message ? err.message : err;
if( res.statusCode === 408 || (error.toLowerCase().indexOf('request timeout') !== -1) ){
res.status(408);
res.json({ error: error === 'string' ? error : 'request time out' });
} else {
next(err);
}
}
module.exports = middleware;