CartoDB-SQL-API/lib/api/middlewares/last-modified.js

15 lines
396 B
JavaScript

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