2019-07-27 01:08:39 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
module.exports = function lastModified () {
|
|
|
|
return function lastModifiedMiddleware (req, res, next) {
|
|
|
|
const { affectedTables } = res.locals;
|
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
if (affectedTables) {
|
2019-07-27 01:08:39 +08:00
|
|
|
const lastUpdatedAt = affectedTables.getLastUpdatedAt(Date.now());
|
|
|
|
res.header('Last-Modified', new Date(lastUpdatedAt).toUTCString());
|
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|