CartoDB-SQL-API/app/middlewares/last-modified.js

15 lines
396 B
JavaScript
Raw Normal View History

'use strict';
module.exports = function lastModified () {
return function lastModifiedMiddleware (req, res, next) {
const { affectedTables } = res.locals;
if(!!affectedTables) {
const lastUpdatedAt = affectedTables.getLastUpdatedAt(Date.now());
res.header('Last-Modified', new Date(lastUpdatedAt).toUTCString());
}
next();
};
};