Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): Convert more routes to use the decorator pattern (no-changelog) #5611

Merged
merged 5 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions packages/cli/src/Ldap/routes/ldap.controller.ee.ts

This file was deleted.

53 changes: 21 additions & 32 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import config from '@/config';
import * as Queue from '@/Queue';
import { getSharedWorkflowIds } from '@/WorkflowHelpers';

import { nodesController } from '@/api/nodes.api';
import { workflowsController } from '@/workflows/workflows.controller';
import {
EDITOR_UI_DIST_DIR,
Expand All @@ -83,16 +82,18 @@ import type {
import { registerController } from '@/decorators';
import {
AuthController,
LdapController,
MeController,
NodesController,
NodeTypesController,
OwnerController,
PasswordResetController,
TagsController,
TranslationController,
UsersController,
} from '@/controllers';

import { executionsController } from '@/executions/executions.controller';
import { nodeTypesController } from '@/api/nodeTypes.api';
import { tagsController } from '@/api/tags.api';
import { workflowStatsController } from '@/api/workflowStats.api';
import { loadPublicApiVersions } from '@/PublicApi';
import {
Expand Down Expand Up @@ -134,7 +135,6 @@ import { licenseController } from './license/license.controller';
import { Push, setupPushServer, setupPushHandler } from '@/push';
import { setupAuthMiddlewares } from './middlewares';
import { initEvents } from './events';
import { ldapController } from './Ldap/routes/ldap.controller.ee';
import { getLdapLoginLabel, isLdapEnabled, isLdapLoginEnabled } from './Ldap/helpers';
import { AbstractServer } from './AbstractServer';
import { configureMetrics } from './metrics';
Expand All @@ -149,6 +149,7 @@ import { getSamlLoginLabel, isSamlLoginEnabled, isSamlLicensed } from './sso/sam
import { samlControllerPublic } from './sso/saml/routes/saml.controller.public.ee';
import { SamlService } from './sso/saml/saml.service.ee';
import { samlControllerProtected } from './sso/saml/routes/saml.controller.protected.ee';
import { LdapManager } from './Ldap/LdapManager.ee';

const exec = promisify(callbackExec);

Expand Down Expand Up @@ -366,7 +367,7 @@ class Server extends AbstractServer {
}

private registerControllers(ignoredEndpoints: Readonly<string[]>) {
const { app, externalHooks, activeWorkflowRunner } = this;
const { app, externalHooks, activeWorkflowRunner, nodeTypes } = this;
const repositories = Db.collections;
setupAuthMiddlewares(app, ignoredEndpoints, this.restEndpoint, repositories.User);

Expand All @@ -375,11 +376,13 @@ class Server extends AbstractServer {
const mailer = getMailerInstance();
const postHog = this.postHog;

const controllers = [
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 TagsController({ config, repositories, externalHooks }),
new TranslationController(config, this.credentialTypes),
new UsersController({
config,
Expand All @@ -392,6 +395,18 @@ class Server extends AbstractServer {
postHog,
}),
];

if (isLdapEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would mean if ldap is enabled at a later point, it would require a restart of the instance (and vice versa) - is that ok?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does mean that unfortunately. But that was already the case.

const { service, sync } = LdapManager.getInstance();
controllers.push(new LdapController(service, sync, internalHooks));
}

if (config.getEnv('nodes.communityPackages.enabled')) {
controllers.push(
new NodesController(config, this.loadNodesAndCredentials, this.push, internalHooks),
);
}

controllers.forEach((controller) => registerController(app, config, controller));
}

Expand Down Expand Up @@ -477,13 +492,6 @@ class Server extends AbstractServer {

this.app.use(`/${this.restEndpoint}/credentials`, credentialsController);

// ----------------------------------------
// Packages and nodes management
// ----------------------------------------
if (config.getEnv('nodes.communityPackages.enabled')) {
this.app.use(`/${this.restEndpoint}/nodes`, nodesController);
}

// ----------------------------------------
// Workflow
// ----------------------------------------
Expand All @@ -499,18 +507,6 @@ class Server extends AbstractServer {
// ----------------------------------------
this.app.use(`/${this.restEndpoint}/workflow-stats`, workflowStatsController);

// ----------------------------------------
// Tags
// ----------------------------------------
this.app.use(`/${this.restEndpoint}/tags`, tagsController);

// ----------------------------------------
// LDAP
// ----------------------------------------
if (isLdapEnabled()) {
this.app.use(`/${this.restEndpoint}/ldap`, ldapController);
}

// ----------------------------------------
// SAML
// ----------------------------------------
Expand All @@ -529,7 +525,6 @@ class Server extends AbstractServer {
this.app.use(`/${this.restEndpoint}/sso/saml`, samlControllerProtected);

// ----------------------------------------

// Returns parameter values which normally get loaded from an external API or
// get generated dynamically
this.app.get(
Expand Down Expand Up @@ -640,12 +635,6 @@ class Server extends AbstractServer {
),
);

// ----------------------------------------
// Node-Types
// ----------------------------------------

this.app.use(`/${this.restEndpoint}/node-types`, nodeTypesController);

// ----------------------------------------
// Active Workflows
// ----------------------------------------
Expand Down
110 changes: 0 additions & 110 deletions packages/cli/src/api/tags.api.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/cli/src/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export { AuthController } from './auth.controller';
export { LdapController } from './ldap.controller';
export { MeController } from './me.controller';
export { NodesController } from './nodes.controller';
export { NodeTypesController } from './nodeTypes.controller';
export { OwnerController } from './owner.controller';
export { PasswordResetController } from './passwordReset.controller';
export { TagsController } from './tags.controller';
export { TranslationController } from './translation.controller';
export { UsersController } from './users.controller';
Loading