diff --git a/packages/cli/src/PublicApi/index.ts b/packages/cli/src/PublicApi/index.ts index 7248b91e72..7c455513d6 100644 --- a/packages/cli/src/PublicApi/index.ts +++ b/packages/cli/src/PublicApi/index.ts @@ -17,6 +17,7 @@ import { InternalHooks } from '@/InternalHooks'; import { License } from '@/License'; import { UserRepository } from '@db/repositories/user.repository'; import { UrlService } from '@/services/url.service'; +import type { AuthenticatedRequest } from '@/requests'; async function createApiRouter( version: string, @@ -51,7 +52,7 @@ async function createApiRouter( ); } - apiController.get(`/${publicApiEndpoint}/${version}/openapi.yml`, (req, res) => { + apiController.get(`/${publicApiEndpoint}/${version}/openapi.yml`, (_, res) => { res.sendFile(openApiSpecPath); }); @@ -91,7 +92,7 @@ async function createApiRouter( validateSecurity: { handlers: { ApiKeyAuth: async ( - req: express.Request, + req: AuthenticatedRequest, _scopes: unknown, schema: OpenAPIV3.ApiKeySecurityScheme, ): Promise => { diff --git a/packages/cli/src/PublicApi/types.ts b/packages/cli/src/PublicApi/types.ts index b57080974b..c7e1bddadf 100644 --- a/packages/cli/src/PublicApi/types.ts +++ b/packages/cli/src/PublicApi/types.ts @@ -1,32 +1,8 @@ -import type express from 'express'; import type { IDataObject, ExecutionStatus } from 'n8n-workflow'; - -import type { User } from '@db/entities/User'; - import type { WorkflowEntity } from '@db/entities/WorkflowEntity'; - import type { TagEntity } from '@db/entities/TagEntity'; - -import type { UserManagementMailer } from '@/UserManagement/email'; - import type { Risk } from '@/security-audit/types'; - -export type AuthlessRequest< - RouteParams = {}, - ResponseBody = {}, - RequestBody = {}, - RequestQuery = {}, -> = express.Request; - -export type AuthenticatedRequest< - RouteParams = {}, - ResponseBody = {}, - RequestBody = {}, - RequestQuery = {}, -> = express.Request & { - user: User; - mailer?: UserManagementMailer; -}; +import type { AuthlessRequest, AuthenticatedRequest } from '@/requests'; export type PaginatedRequest = AuthenticatedRequest< {}, diff --git a/packages/cli/src/PublicApi/v1/shared/middlewares/global.middleware.ts b/packages/cli/src/PublicApi/v1/shared/middlewares/global.middleware.ts index 97501f0466..6baf96607e 100644 --- a/packages/cli/src/PublicApi/v1/shared/middlewares/global.middleware.ts +++ b/packages/cli/src/PublicApi/v1/shared/middlewares/global.middleware.ts @@ -1,12 +1,13 @@ /* eslint-disable @typescript-eslint/no-invalid-void-type */ - import type express from 'express'; import { Container } from 'typedi'; -import type { AuthenticatedRequest, PaginatedRequest } from '../../../types'; -import { decodeCursor } from '../services/pagination.service'; import { License } from '@/License'; import type { GlobalRole } from '@db/entities/User'; +import type { AuthenticatedRequest } from '@/requests'; + +import type { PaginatedRequest } from '../../../types'; +import { decodeCursor } from '../services/pagination.service'; const UNLIMITED_USERS_QUOTA = -1; @@ -51,7 +52,7 @@ export const validCursor = ( }; export const validLicenseWithUserQuota = ( - req: express.Request, + _: express.Request, res: express.Response, next: express.NextFunction, ): express.Response | void => { diff --git a/packages/cli/src/requests.ts b/packages/cli/src/requests.ts index cdcd1bffe1..4b64f844a9 100644 --- a/packages/cli/src/requests.ts +++ b/packages/cli/src/requests.ts @@ -15,7 +15,6 @@ import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, Length } from 'class-va import { NoXss } from '@db/utils/customValidators'; import type { PublicUser, SecretsProvider, SecretsProviderState } from '@/Interfaces'; import { AssignableRole, type User } from '@db/entities/User'; -import type { UserManagementMailer } from '@/UserManagement/email'; import type { Variables } from '@db/entities/Variables'; import type { WorkflowEntity } from '@db/entities/WorkflowEntity'; import type { CredentialsEntity } from '@db/entities/CredentialsEntity'; @@ -65,7 +64,6 @@ export type AuthenticatedRequest< RequestQuery = {}, > = Omit, 'user'> & { user: User; - mailer?: UserManagementMailer; }; // ----------------------------------