mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
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
@@ -12,6 +12,9 @@ import {
|
||||
import { CredentialsHelper } from '@/CredentialsHelper';
|
||||
import { CredentialTypes } from '@/CredentialTypes';
|
||||
import * as Helpers from './Helpers';
|
||||
import { Container } from 'typedi';
|
||||
import { NodeTypes } from '@/NodeTypes';
|
||||
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||
|
||||
const TEST_ENCRYPTION_KEY = 'test';
|
||||
const mockNodesAndCredentials: INodesAndCredentials = {
|
||||
@@ -19,6 +22,7 @@ const mockNodesAndCredentials: INodesAndCredentials = {
|
||||
known: { nodes: {}, credentials: {} },
|
||||
credentialTypes: {} as ICredentialTypes,
|
||||
};
|
||||
Container.set(LoadNodesAndCredentials, mockNodesAndCredentials);
|
||||
|
||||
describe('CredentialsHelper', () => {
|
||||
describe('authenticate', () => {
|
||||
@@ -215,7 +219,7 @@ describe('CredentialsHelper', () => {
|
||||
qs: {},
|
||||
};
|
||||
|
||||
const nodeTypes = Helpers.NodeTypes();
|
||||
const nodeTypes = Helpers.NodeTypes() as unknown as NodeTypes;
|
||||
|
||||
const workflow = new Workflow({
|
||||
nodes: [node],
|
||||
@@ -235,7 +239,7 @@ describe('CredentialsHelper', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const credentialTypes = CredentialTypes(mockNodesAndCredentials);
|
||||
const credentialTypes = Container.get(CredentialTypes);
|
||||
|
||||
const credentialsHelper = new CredentialsHelper(
|
||||
TEST_ENCRYPTION_KEY,
|
||||
|
||||
Reference in New Issue
Block a user