mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Convert more routes to use the decorator pattern (no-changelog) (#5611)
* move nodeTypes api to a controller class * move tags api to a controller class * move LDAP routes to a controller class * move nodes routes to a controller class
This commit is contained in:
committed by
GitHub
parent
493f7a1c92
commit
356e916194
@@ -31,11 +31,8 @@ import { DeepPartial } from 'ts-essentials';
|
||||
import config from '@/config';
|
||||
import * as Db from '@/Db';
|
||||
import { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import { CredentialTypes } from '@/CredentialTypes';
|
||||
import { ExternalHooks } from '@/ExternalHooks';
|
||||
import { NodeTypes } from '@/NodeTypes';
|
||||
import { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
|
||||
import { nodesController } from '@/api/nodes.api';
|
||||
import { workflowsController } from '@/workflows/workflows.controller';
|
||||
import { AUTH_COOKIE_NAME, NODE_PACKAGE_PREFIX } from '@/constants';
|
||||
import { credentialsController } from '@/credentials/credentials.controller';
|
||||
@@ -65,7 +62,9 @@ import { eventBusRouter } from '@/eventbus/eventBusRoutes';
|
||||
import { registerController } from '@/decorators';
|
||||
import {
|
||||
AuthController,
|
||||
LdapController,
|
||||
MeController,
|
||||
NodesController,
|
||||
OwnerController,
|
||||
PasswordResetController,
|
||||
UsersController,
|
||||
@@ -74,11 +73,13 @@ import { setupAuthMiddlewares } from '@/middlewares';
|
||||
import * as testDb from '../shared/testDb';
|
||||
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { handleLdapInit } from '@/Ldap/helpers';
|
||||
import { ldapController } from '@/Ldap/routes/ldap.controller.ee';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||
import { PostHogClient } from '@/posthog';
|
||||
import { LdapManager } from '@/Ldap/LdapManager.ee';
|
||||
import { LDAP_ENABLED } from '@/Ldap/constants';
|
||||
import { handleLdapInit } from '@/Ldap/helpers';
|
||||
import { Push } from '@/push';
|
||||
|
||||
export const mockInstance = <T>(
|
||||
ctor: new (...args: any[]) => T,
|
||||
@@ -155,10 +156,8 @@ export async function initTestServer({
|
||||
const map: Record<string, express.Router | express.Router[] | any> = {
|
||||
credentials: { controller: credentialsController, path: 'credentials' },
|
||||
workflows: { controller: workflowsController, path: 'workflows' },
|
||||
nodes: { controller: nodesController, path: 'nodes' },
|
||||
license: { controller: licenseController, path: 'license' },
|
||||
eventBus: { controller: eventBusRouter, path: 'eventbus' },
|
||||
ldap: { controller: ldapController, path: 'ldap' },
|
||||
};
|
||||
|
||||
if (enablePublicAPI) {
|
||||
@@ -190,6 +189,27 @@ export async function initTestServer({
|
||||
new AuthController({ config, logger, internalHooks, repositories }),
|
||||
);
|
||||
break;
|
||||
case 'ldap':
|
||||
config.set(LDAP_ENABLED, true);
|
||||
await handleLdapInit();
|
||||
const { service, sync } = LdapManager.getInstance();
|
||||
registerController(
|
||||
testServer.app,
|
||||
config,
|
||||
new LdapController(service, sync, internalHooks),
|
||||
);
|
||||
break;
|
||||
case 'nodes':
|
||||
registerController(
|
||||
testServer.app,
|
||||
config,
|
||||
new NodesController(
|
||||
config,
|
||||
Container.get(LoadNodesAndCredentials),
|
||||
Container.get(Push),
|
||||
internalHooks,
|
||||
),
|
||||
);
|
||||
case 'me':
|
||||
registerController(
|
||||
testServer.app,
|
||||
@@ -246,15 +266,7 @@ const classifyEndpointGroups = (endpointGroups: EndpointGroup[]) => {
|
||||
const routerEndpoints: EndpointGroup[] = [];
|
||||
const functionEndpoints: EndpointGroup[] = [];
|
||||
|
||||
const ROUTER_GROUP = [
|
||||
'credentials',
|
||||
'nodes',
|
||||
'workflows',
|
||||
'publicApi',
|
||||
'ldap',
|
||||
'eventBus',
|
||||
'license',
|
||||
];
|
||||
const ROUTER_GROUP = ['credentials', 'workflows', 'publicApi', 'eventBus', 'license'];
|
||||
|
||||
endpointGroups.forEach((group) =>
|
||||
(ROUTER_GROUP.includes(group) ? routerEndpoints : functionEndpoints).push(group),
|
||||
@@ -320,13 +332,6 @@ export async function initCredentialsTypes(): Promise<void> {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize LDAP manager.
|
||||
*/
|
||||
export async function initLdapManager(): Promise<void> {
|
||||
await handleLdapInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize node types.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user