refactor(core): Use an IoC container to manage singleton classes [Part-1] (no-changelog) (#5509)
* add typedi * convert ActiveWorkflowRunner into an injectable service * convert ExternalHooks into an injectable service * convert InternalHooks into an injectable service * convert LoadNodesAndCredentials into an injectable service * convert NodeTypes and CredentialTypes into an injectable service * convert ActiveExecutions into an injectable service * convert WaitTracker into an injectable service * convert Push into an injectable service * convert ActiveWebhooks and TestWebhooks into an injectable services * handle circular references, and log errors when a circular dependency is found
This commit is contained in:
committed by
GitHub
parent
aca94bb995
commit
52f740b9e8
@@ -1,7 +1,6 @@
|
||||
import express from 'express';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import * as Db from '@/Db';
|
||||
import { InternalHooksManager } from '@/InternalHooksManager';
|
||||
import * as ResponseHelper from '@/ResponseHelper';
|
||||
import * as WorkflowHelpers from '@/WorkflowHelpers';
|
||||
import config from '@/config';
|
||||
@@ -18,6 +17,8 @@ import { EECredentialsService as EECredentials } from '../credentials/credential
|
||||
import type { IExecutionPushResponse } from '@/Interfaces';
|
||||
import * as GenericHelpers from '@/GenericHelpers';
|
||||
import { In } from 'typeorm';
|
||||
import { Container } from 'typedi';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const EEWorkflowController = express.Router();
|
||||
@@ -75,7 +76,7 @@ EEWorkflowController.put(
|
||||
}
|
||||
});
|
||||
|
||||
void InternalHooksManager.getInstance().onWorkflowSharingUpdate(
|
||||
void Container.get(InternalHooks).onWorkflowSharingUpdate(
|
||||
workflowId,
|
||||
req.user.id,
|
||||
shareWithIds,
|
||||
@@ -126,7 +127,7 @@ EEWorkflowController.post(
|
||||
|
||||
await validateEntity(newWorkflow);
|
||||
|
||||
await ExternalHooks().run('workflow.create', [newWorkflow]);
|
||||
await Container.get(ExternalHooks).run('workflow.create', [newWorkflow]);
|
||||
|
||||
const { tags: tagIds } = req.body;
|
||||
|
||||
@@ -190,8 +191,8 @@ EEWorkflowController.post(
|
||||
});
|
||||
}
|
||||
|
||||
await ExternalHooks().run('workflow.afterCreate', [savedWorkflow]);
|
||||
void InternalHooksManager.getInstance().onWorkflowCreated(req.user, newWorkflow, false);
|
||||
await Container.get(ExternalHooks).run('workflow.afterCreate', [savedWorkflow]);
|
||||
void Container.get(InternalHooks).onWorkflowCreated(req.user, newWorkflow, false);
|
||||
|
||||
return savedWorkflow;
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user