refactor: Revert "refactor(core): Use typedi to manage EventBus singletons (#5795)" (no-changelog) (#5825)

Revert "refactor(core): Use typedi to manage EventBus singletons (no-changelog) (#5795)"

This reverts commit 522c790817.
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-03-30 09:59:04 +02:00
committed by GitHub
parent 6c35ffa82c
commit 58fda255fe
15 changed files with 154 additions and 145 deletions

View File

@@ -146,6 +146,7 @@ import { configureMetrics } from './metrics';
import { setupBasicAuth } from './middlewares/basicAuth';
import { setupExternalJWTAuth } from './middlewares/externalJWTAuth';
import { PostHogClient } from './posthog';
import { eventBus } from './eventbus';
import { Container } from 'typedi';
import { InternalHooks } from './InternalHooks';
import {
@@ -156,7 +157,6 @@ import { getSamlLoginLabel, isSamlLoginEnabled, isSamlLicensed } from './sso/sam
import { SamlController } from './sso/saml/routes/saml.controller.ee';
import { SamlService } from './sso/saml/saml.service.ee';
import { LdapManager } from './Ldap/LdapManager.ee';
import { MessageEventBus } from '@/eventbus';
const exec = promisify(callbackExec);
@@ -365,7 +365,7 @@ class Server extends AbstractServer {
return this.frontendSettings;
}
private async registerControllers(ignoredEndpoints: Readonly<string[]>) {
private registerControllers(ignoredEndpoints: Readonly<string[]>) {
const { app, externalHooks, activeWorkflowRunner, nodeTypes } = this;
const repositories = Db.collections;
setupAuthMiddlewares(app, ignoredEndpoints, this.restEndpoint, repositories.User);
@@ -376,11 +376,8 @@ class Server extends AbstractServer {
const postHog = this.postHog;
const samlService = Container.get(SamlService);
const eventBus = Container.get(MessageEventBus);
await eventBus.initialize();
const controllers: object[] = [
new EventBusController(eventBus),
new EventBusController(),
new AuthController({ config, internalHooks, repositories, logger, postHog }),
new OwnerController({ config, internalHooks, repositories, logger }),
new MeController({ externalHooks, internalHooks, repositories, logger }),
@@ -500,7 +497,7 @@ class Server extends AbstractServer {
await handleLdapInit();
await this.registerControllers(ignoredEndpoints);
this.registerControllers(ignoredEndpoints);
this.app.use(`/${this.restEndpoint}/credentials`, credentialsController);
@@ -1226,6 +1223,14 @@ class Server extends AbstractServer {
),
);
// ----------------------------------------
// EventBus Setup
// ----------------------------------------
if (!eventBus.isInitialized) {
await eventBus.initialize();
}
// ----------------------------------------
// Webhooks
// ----------------------------------------