mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
61e1b19d46
- This is a precursor to trying to split apart into:
- model events + webhooks system which makes sense
- frontend events which should be independent or removed
- maybe some concept of a settings manager that we can use in various places to bind logic 🤔
- other usages of events that should be refactored to not use events
16 lines
452 B
JavaScript
16 lines
452 B
JavaScript
const INVALIDATE_ALL = '/*';
|
|
|
|
// Emit the site.changed event, a special model event used for webhooks
|
|
const events = require('../../../lib/common/events');
|
|
|
|
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();
|
|
};
|