refactor(core): Port endpoints config (no-changelog) (#10268)

This commit is contained in:
Iván Ovejero
2024-07-31 17:45:11 +02:00
committed by GitHub
parent d91eb2cdd5
commit 1608d2527b
21 changed files with 275 additions and 228 deletions

View File

@@ -4,7 +4,6 @@ import type { Application, Request, Response, RequestHandler } from 'express';
import { rateLimit as expressRateLimit } from 'express-rate-limit';
import { AuthService } from '@/auth/auth.service';
import config from '@/config';
import { UnauthenticatedError } from '@/errors/response-errors/unauthenticated.error';
import { inProduction, RESPONSE_ERROR_MESSAGES } from '@/constants';
import type { BooleanLicenseFeature } from '@/Interfaces';
@@ -12,7 +11,7 @@ import { License } from '@/License';
import type { AuthenticatedRequest } from '@/requests';
import { send } from '@/ResponseHelper'; // TODO: move `ResponseHelper.send` to this file
import { userHasScope } from '@/permissions/checkAccess';
import { GlobalConfig } from '@n8n/config';
import type {
AccessScope,
Controller,
@@ -52,6 +51,7 @@ export class ControllerRegistry {
constructor(
private readonly license: License,
private readonly authService: AuthService,
private readonly globalConfig: GlobalConfig,
) {}
activate(app: Application) {
@@ -64,7 +64,7 @@ export class ControllerRegistry {
const metadata = registry.get(controllerClass)!;
const router = Router({ mergeParams: true });
const prefix = `/${config.getEnv('endpoints.rest')}/${metadata.basePath}`
const prefix = `/${this.globalConfig.endpoints.rest}/${metadata.basePath}`
.replace(/\/+/g, '/')
.replace(/\/$/, '');
app.use(prefix, router);