mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 21:03:29 +03:00
Extracted domain event interceptor to separate init
closes https://github.com/TryGhost/Arch/issues/13 - Model to Domain event interceptor is a class that does not strictly belong to Collections. It's supposed to be used in any new code that depends on legacy bookshelf model events. Extracted it's initialization to it's own service for clarity and visibility.
This commit is contained in:
parent
5989ea0ffa
commit
dc7b20d50b
@ -326,6 +326,7 @@ async function initServices({config}) {
|
|||||||
const slackNotifications = require('./server/services/slack-notifications');
|
const slackNotifications = require('./server/services/slack-notifications');
|
||||||
const mediaInliner = require('./server/services/media-inliner');
|
const mediaInliner = require('./server/services/media-inliner');
|
||||||
const collections = require('./server/services/collections');
|
const collections = require('./server/services/collections');
|
||||||
|
const modelToDomainEventInterceptor = require('./server/services/model-to-domain-event-interceptor');
|
||||||
const mailEvents = require('./server/services/mail-events');
|
const mailEvents = require('./server/services/mail-events');
|
||||||
const donationService = require('./server/services/donations');
|
const donationService = require('./server/services/donations');
|
||||||
|
|
||||||
@ -365,6 +366,7 @@ async function initServices({config}) {
|
|||||||
emailSuppressionList.init(),
|
emailSuppressionList.init(),
|
||||||
slackNotifications.init(),
|
slackNotifications.init(),
|
||||||
collections.init(),
|
collections.init(),
|
||||||
|
modelToDomainEventInterceptor.init(),
|
||||||
mediaInliner.init(),
|
mediaInliner.init(),
|
||||||
mailEvents.init(),
|
mailEvents.init(),
|
||||||
donationService.init()
|
donationService.init()
|
||||||
|
@ -36,7 +36,6 @@ class CollectionsServiceWrapper {
|
|||||||
}
|
}
|
||||||
inited = true;
|
inited = true;
|
||||||
this.api.subscribeToEvents();
|
this.api.subscribeToEvents();
|
||||||
require('./intercept-events')();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
module.exports = () => {
|
let inited = false;
|
||||||
|
|
||||||
|
module.exports.init = async () => {
|
||||||
|
if (inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inited = true;
|
||||||
|
|
||||||
const DomainEvents = require('@tryghost/domain-events/lib/DomainEvents');
|
const DomainEvents = require('@tryghost/domain-events/lib/DomainEvents');
|
||||||
const {ModelToDomainEventInterceptor} = require('@tryghost/model-to-domain-event-interceptor');
|
const {ModelToDomainEventInterceptor} = require('@tryghost/model-to-domain-event-interceptor');
|
||||||
const events = require('../../lib/common/events');
|
const events = require('../../lib/common/events');
|
||||||
@ -6,5 +13,6 @@ module.exports = () => {
|
|||||||
ModelEvents: events,
|
ModelEvents: events,
|
||||||
DomainEvents: DomainEvents
|
DomainEvents: DomainEvents
|
||||||
});
|
});
|
||||||
|
|
||||||
eventInterceptor.init();
|
eventInterceptor.init();
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user