CartoDB-SQL-API/lib/api/middlewares/cancel-on-client-abort.js

14 lines
341 B
JavaScript
Raw Normal View History

'use strict';
module.exports = function cancelOnClientAbort () {
return function cancelOnClientAbortMiddleware (req, res, next) {
req.on('aborted', () => {
if (req.formatter && typeof req.formatter.cancel === 'function') {
req.formatter.cancel();
}
});
next();
};
};