mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Port endpoints config (no-changelog) (#10268)
This commit is contained in:
@@ -6,7 +6,6 @@ import { promisify } from 'util';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import express from 'express';
|
||||
import helmet from 'helmet';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
import type { IN8nUISettings } from 'n8n-workflow';
|
||||
|
||||
@@ -81,17 +80,16 @@ export class Server extends AbstractServer {
|
||||
private readonly loadNodesAndCredentials: LoadNodesAndCredentials,
|
||||
private readonly orchestrationService: OrchestrationService,
|
||||
private readonly postHogClient: PostHogClient,
|
||||
private readonly globalConfig: GlobalConfig,
|
||||
private readonly eventService: EventService,
|
||||
) {
|
||||
super('main');
|
||||
|
||||
this.testWebhooksEnabled = true;
|
||||
this.webhooksEnabled = !config.getEnv('endpoints.disableProductionWebhooksOnMainProcess');
|
||||
this.webhooksEnabled = !this.globalConfig.endpoints.disableProductionWebhooksOnMainProcess;
|
||||
}
|
||||
|
||||
async start() {
|
||||
if (!config.getEnv('endpoints.disableUi')) {
|
||||
if (!this.globalConfig.endpoints.disableUi) {
|
||||
const { FrontendService } = await import('@/services/frontend.service');
|
||||
this.frontendService = Container.get(FrontendService);
|
||||
}
|
||||
@@ -133,7 +131,7 @@ export class Server extends AbstractServer {
|
||||
await import('@/controllers/mfa.controller');
|
||||
}
|
||||
|
||||
if (!config.getEnv('endpoints.disableUi')) {
|
||||
if (!this.globalConfig.endpoints.disableUi) {
|
||||
await import('@/controllers/cta.controller');
|
||||
}
|
||||
|
||||
@@ -167,7 +165,7 @@ export class Server extends AbstractServer {
|
||||
}
|
||||
|
||||
async configure(): Promise<void> {
|
||||
if (config.getEnv('endpoints.metrics.enable')) {
|
||||
if (this.globalConfig.endpoints.metrics.enable) {
|
||||
const { PrometheusMetricsService } = await import('@/metrics/prometheus-metrics.service');
|
||||
await Container.get(PrometheusMetricsService).init(this.app);
|
||||
}
|
||||
@@ -307,7 +305,8 @@ export class Server extends AbstractServer {
|
||||
this.app.use('/icons/@:scope/:packageName/*/*.(svg|png)', serveIcons);
|
||||
this.app.use('/icons/:packageName/*/*.(svg|png)', serveIcons);
|
||||
|
||||
const isTLSEnabled = this.protocol === 'https' && !!(this.sslKey && this.sslCert);
|
||||
const isTLSEnabled =
|
||||
this.globalConfig.protocol === 'https' && !!(this.sslKey && this.sslCert);
|
||||
const isPreviewMode = process.env.N8N_PREVIEW_MODE === 'true';
|
||||
const securityHeadersMiddleware = helmet({
|
||||
contentSecurityPolicy: false,
|
||||
@@ -341,7 +340,7 @@ export class Server extends AbstractServer {
|
||||
this.restEndpoint,
|
||||
this.endpointPresetCredentials,
|
||||
isApiEnabled() ? '' : publicApiEndpoint,
|
||||
...config.getEnv('endpoints.additionalNonUIRoutes').split(':'),
|
||||
...this.globalConfig.endpoints.additionalNonUIRoutes.split(':'),
|
||||
].filter((u) => !!u);
|
||||
const nonUIRoutesRegex = new RegExp(`^/(${nonUIRoutes.join('|')})/?.*$`);
|
||||
const historyApiHandler: express.RequestHandler = (req, res, next) => {
|
||||
|
||||
Reference in New Issue
Block a user