CartoDB-SQL-API/lib/api/middlewares/socket-timeout.js

19 lines
495 B
JavaScript
Raw Normal View History

2019-10-01 21:36:04 +08:00
'use strict';
module.exports = function socketTimeout () {
2019-12-27 01:28:01 +08:00
if (!Object.prototype.hasOwnProperty.call(global.settings, 'node_socket_timeout')) {
2019-10-01 21:36:04 +08:00
return function dummySocketTimeoutMiddleware (req, res, next) {
next();
};
}
const timeout = parseInt(global.settings.node_socket_timeout);
return function socketTimeoutMiddleware (req, res, next) {
// Set connection timeout
req.connection.setTimeout(timeout);
next();
2019-10-01 21:42:24 +08:00
};
};