refactor(core): Use typedi to manage EventBus singletons (no-changelog) (#5795)
This commit is contained in:
committed by
GitHub
parent
be373bb859
commit
522c790817
@@ -1,3 +1,4 @@
|
||||
import { Container } from 'typedi';
|
||||
import express from 'express';
|
||||
import config from '@/config';
|
||||
import axios from 'axios';
|
||||
@@ -16,7 +17,7 @@ import {
|
||||
MessageEventBusDestinationSyslogOptions,
|
||||
MessageEventBusDestinationWebhookOptions,
|
||||
} from 'n8n-workflow';
|
||||
import { eventBus } from '@/eventbus';
|
||||
import { MessageEventBus } from '@/eventbus/MessageEventBus/MessageEventBus';
|
||||
import { EventMessageGeneric } from '@/eventbus/EventMessageClasses/EventMessageGeneric';
|
||||
import { MessageEventBusDestinationSyslog } from '@/eventbus/MessageEventBusDestination/MessageEventBusDestinationSyslog.ee';
|
||||
import { MessageEventBusDestinationWebhook } from '@/eventbus/MessageEventBusDestination/MessageEventBusDestinationWebhook.ee';
|
||||
@@ -64,6 +65,8 @@ const testSentryDestination: MessageEventBusDestinationSentryOptions = {
|
||||
subscribedEvents: ['n8n.test.message', 'n8n.audit.user.updated'],
|
||||
};
|
||||
|
||||
const eventBus = Container.get(MessageEventBus);
|
||||
|
||||
async function confirmIdInAll(id: string) {
|
||||
const sent = await eventBus.getEventsAll();
|
||||
expect(sent.length).toBeGreaterThan(0);
|
||||
|
||||
@@ -81,6 +81,7 @@ import { setSamlLoginEnabled } from '@/sso/saml/samlHelpers';
|
||||
import { SamlService } from '@/sso/saml/saml.service.ee';
|
||||
import { SamlController } from '@/sso/saml/routes/saml.controller.ee';
|
||||
import { EventBusController } from '@/eventbus/eventBus.controller';
|
||||
import { MessageEventBus } from '@/eventbus';
|
||||
|
||||
export const mockInstance = <T>(
|
||||
ctor: new (...args: any[]) => T,
|
||||
@@ -176,7 +177,8 @@ export async function initTestServer({
|
||||
for (const group of functionEndpoints) {
|
||||
switch (group) {
|
||||
case 'eventBus':
|
||||
registerController(testServer.app, config, new EventBusController());
|
||||
const eventBus = Container.get(MessageEventBus);
|
||||
registerController(testServer.app, config, new EventBusController(eventBus));
|
||||
break;
|
||||
case 'auth':
|
||||
registerController(
|
||||
|
||||
Reference in New Issue
Block a user