Ghost/core/server/web/parent/middleware/emit-events.js
Hannah Wolfe 295eac6ea1 Moved emit-events mw into parent app
- Moved emit-events from shared to parent as it is not shared
- This file is only used in one place, this updates the code structure to reflect this
- This is one of many similar changes needed to make it easier to refactor to the existing setup
2020-04-21 18:36:42 +01:00

14 lines
374 B
JavaScript

const {events} = 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) {
events.emit('site.changed');
}
res.removeListener('finish', triggerEvents);
});
next();
};