mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Extract Invitation routes to InvitationController (no-changelog) (#7726)
This PR: - Creates `InvitationController` - Moves `POST /users` to `POST /invitations` and move related test to `invitations.api.tests` - Moves `POST /users/:id` to `POST /invitations/:id/accept` and move related test to `invitations.api.tests` - Adjusts FE to use new endpoints - Moves all the invitation logic to the `UserService` --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -11,7 +11,6 @@ import type { User } from '@db/entities/User';
|
||||
import { issueJWT } from '@/auth/jwt';
|
||||
import { registerController } from '@/decorators';
|
||||
import { rawBodyReader, bodyParser, setupAuthMiddlewares } from '@/middlewares';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { PostHogClient } from '@/posthog';
|
||||
import { License } from '@/License';
|
||||
import { Logger } from '@/Logger';
|
||||
@@ -20,6 +19,7 @@ import { mockInstance } from '../../../shared/mocking';
|
||||
import * as testDb from '../../shared/testDb';
|
||||
import { AUTHLESS_ENDPOINTS, PUBLIC_API_REST_PATH_SEGMENT, REST_PATH_SEGMENT } from '../constants';
|
||||
import type { SetupProps, TestServer } from '../types';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
|
||||
/**
|
||||
* Plugin to prefix a path segment into a request URL pathname.
|
||||
@@ -234,33 +234,44 @@ export const setupTestServer = ({
|
||||
'@db/repositories/sharedWorkflow.repository'
|
||||
);
|
||||
const { ActiveWorkflowRunner } = await import('@/ActiveWorkflowRunner');
|
||||
const { ExternalHooks } = await import('@/ExternalHooks');
|
||||
const { JwtService } = await import('@/services/jwt.service');
|
||||
const { RoleService } = await import('@/services/role.service');
|
||||
const { UserService: US } = await import('@/services/user.service');
|
||||
const { UserManagementMailer } = await import(
|
||||
'@/UserManagement/email/UserManagementMailer'
|
||||
);
|
||||
const { ExternalHooks: EH } = await import('@/ExternalHooks');
|
||||
const { RoleService: RS } = await import('@/services/role.service');
|
||||
const { UsersController } = await import('@/controllers/users.controller');
|
||||
registerController(
|
||||
app,
|
||||
config,
|
||||
new UsersController(
|
||||
config,
|
||||
logger,
|
||||
Container.get(ExternalHooks),
|
||||
Container.get(EH),
|
||||
Container.get(InternalHooks),
|
||||
Container.get(SharedCredentialsRepository),
|
||||
Container.get(SharedWorkflowRepository),
|
||||
Container.get(ActiveWorkflowRunner),
|
||||
Container.get(UserManagementMailer),
|
||||
Container.get(JwtService),
|
||||
Container.get(RoleService),
|
||||
Container.get(RS),
|
||||
Container.get(US),
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'invitations':
|
||||
const { InvitationController } = await import('@/controllers/invitation.controller');
|
||||
const { ExternalHooks: EHS } = await import('@/ExternalHooks');
|
||||
const { UserService: USE } = await import('@/services/user.service');
|
||||
|
||||
registerController(
|
||||
app,
|
||||
config,
|
||||
new InvitationController(
|
||||
config,
|
||||
logger,
|
||||
Container.get(InternalHooks),
|
||||
Container.get(EHS),
|
||||
Container.get(USE),
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'tags':
|
||||
const { TagsController } = await import('@/controllers/tags.controller');
|
||||
registerController(app, config, Container.get(TagsController));
|
||||
|
||||
Reference in New Issue
Block a user