mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
295eac6ea1
- 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
14 lines
374 B
JavaScript
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();
|
|
};
|