0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/server/web/shared/middlewares/emit-events.js

14 lines
379 B
JavaScript
Raw Normal View History

const common = require('../../../lib/common');
const INVALIDATE_ALL = '/*';
module.exports = function emitEvents(req, res, next) {
res.on('finish', function triggerEvents() {
if (res.get('X-Cache-Invalidate') === INVALIDATE_ALL) {
common.events.emit('site.changed');
}
res.removeListener('finish', triggerEvents);
});
next();
};