mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +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 mediaInliner = require('./server/services/media-inliner');
|
||||
const collections = require('./server/services/collections');
|
||||
const modelToDomainEventInterceptor = require('./server/services/model-to-domain-event-interceptor');
|
||||
const mailEvents = require('./server/services/mail-events');
|
||||
const donationService = require('./server/services/donations');
|
||||
|
||||
@ -365,6 +366,7 @@ async function initServices({config}) {
|
||||
emailSuppressionList.init(),
|
||||
slackNotifications.init(),
|
||||
collections.init(),
|
||||
modelToDomainEventInterceptor.init(),
|
||||
mediaInliner.init(),
|
||||
mailEvents.init(),
|
||||
donationService.init()
|
||||
|
@ -36,7 +36,6 @@ class CollectionsServiceWrapper {
|
||||
}
|
||||
inited = true;
|
||||
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 {ModelToDomainEventInterceptor} = require('@tryghost/model-to-domain-event-interceptor');
|
||||
const events = require('../../lib/common/events');
|
||||
@ -6,5 +13,6 @@ module.exports = () => {
|
||||
ModelEvents: events,
|
||||
DomainEvents: DomainEvents
|
||||
});
|
||||
|
||||
eventInterceptor.init();
|
||||
};
|
Loading…
Reference in New Issue
Block a user