mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Use an IoC container to manage singleton classes [Part-2] (no-changelog) (#5690)
* use typedi for UserManagementMailer * use typedi for SamlService * fix typos * use typedi for Queue * use typedi for License * convert some more code to use typedi
This commit is contained in:
committed by
GitHub
parent
c07f838ce6
commit
9bd7529193
@@ -56,7 +56,7 @@ import timezones from 'google-timezones-json';
|
||||
import history from 'connect-history-api-fallback';
|
||||
|
||||
import config from '@/config';
|
||||
import * as Queue from '@/Queue';
|
||||
import { Queue } from '@/Queue';
|
||||
import { getSharedWorkflowIds } from '@/WorkflowHelpers';
|
||||
|
||||
import { workflowsController } from '@/workflows/workflows.controller';
|
||||
@@ -103,7 +103,7 @@ import {
|
||||
isUserManagementEnabled,
|
||||
whereClause,
|
||||
} from '@/UserManagement/UserManagementHelper';
|
||||
import { getInstance as getMailerInstance } from '@/UserManagement/email';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
import * as Db from '@/Db';
|
||||
import type {
|
||||
ICredentialsDb,
|
||||
@@ -367,16 +367,23 @@ class Server extends AbstractServer {
|
||||
|
||||
const logger = LoggerProxy;
|
||||
const internalHooks = Container.get(InternalHooks);
|
||||
const mailer = getMailerInstance();
|
||||
const mailer = Container.get(UserManagementMailer);
|
||||
const postHog = this.postHog;
|
||||
const samlService = SamlService.getInstance();
|
||||
const samlService = Container.get(SamlService);
|
||||
|
||||
const controllers: object[] = [
|
||||
new AuthController({ config, internalHooks, repositories, logger, postHog }),
|
||||
new OwnerController({ config, internalHooks, repositories, logger }),
|
||||
new MeController({ externalHooks, internalHooks, repositories, logger }),
|
||||
new NodeTypesController({ config, nodeTypes }),
|
||||
new PasswordResetController({ config, externalHooks, internalHooks, repositories, logger }),
|
||||
new PasswordResetController({
|
||||
config,
|
||||
externalHooks,
|
||||
internalHooks,
|
||||
mailer,
|
||||
repositories,
|
||||
logger,
|
||||
}),
|
||||
new TagsController({ config, repositories, externalHooks }),
|
||||
new TranslationController(config, this.credentialTypes),
|
||||
new UsersController({
|
||||
@@ -480,6 +487,10 @@ class Server extends AbstractServer {
|
||||
}),
|
||||
);
|
||||
|
||||
if (config.getEnv('executions.mode') === 'queue') {
|
||||
await Container.get(Queue).init();
|
||||
}
|
||||
|
||||
await handleLdapInit();
|
||||
|
||||
this.registerControllers(ignoredEndpoints);
|
||||
@@ -509,7 +520,7 @@ class Server extends AbstractServer {
|
||||
// set up the initial environment
|
||||
if (isSamlLicensed()) {
|
||||
try {
|
||||
await SamlService.getInstance().init();
|
||||
await Container.get(SamlService).init();
|
||||
} catch (error) {
|
||||
LoggerProxy.error(`SAML initialization failed: ${error.message}`);
|
||||
}
|
||||
@@ -953,7 +964,7 @@ class Server extends AbstractServer {
|
||||
ResponseHelper.send(
|
||||
async (req: ExecutionRequest.GetAllCurrent): Promise<IExecutionsSummary[]> => {
|
||||
if (config.getEnv('executions.mode') === 'queue') {
|
||||
const queue = await Queue.getInstance();
|
||||
const queue = Container.get(Queue);
|
||||
const currentJobs = await queue.getJobs(['active', 'waiting']);
|
||||
|
||||
const currentlyRunningQueueIds = currentJobs.map((job) => job.data.executionId);
|
||||
@@ -1096,7 +1107,7 @@ class Server extends AbstractServer {
|
||||
} as IExecutionsStopData;
|
||||
}
|
||||
|
||||
const queue = await Queue.getInstance();
|
||||
const queue = Container.get(Queue);
|
||||
const currentJobs = await queue.getJobs(['active', 'waiting']);
|
||||
|
||||
const job = currentJobs.find((job) => job.data.executionId === req.params.id);
|
||||
|
||||
Reference in New Issue
Block a user