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

14 lines
341 B
JavaScript

'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();
};
};