Skip to content

Commit

Permalink
BC-8460 - Solve circular imports in board collaboration module (#5359)
Browse files Browse the repository at this point in the history
Co-authored-by: Cedric Evers <[email protected]>
Co-authored-by: hoeppner.dataport <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent c521ae5 commit 4b26336
Show file tree
Hide file tree
Showing 32 changed files with 78 additions and 93 deletions.
10 changes: 5 additions & 5 deletions apps/server/src/apps/board-collaboration.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { install as sourceMapInstall } from 'source-map-support';
// application imports
import { SwaggerDocumentOptions } from '@nestjs/swagger';
import { LegacyLogger, Logger } from '@src/core/logger';
import { RedisIoAdapter } from '@src/infra/socketio';
import { BoardCollaborationModule } from '@src/modules/board/board-collaboration.module';
import { enableOpenApiDocs } from '@src/shared/controller/swagger';
import { RedisIoAdapter } from '@infra/socketio';
import { BoardCollaborationModule } from '@modules/board/board-collaboration.app.module';
import { enableOpenApiDocs } from '@shared/controller/swagger';
import express from 'express';
import { ExpressAdapter } from '@nestjs/platform-express';
import {
addPrometheusMetricsMiddlewaresIfEnabled,
createAndStartPrometheusMetricsAppIfEnabled,
} from '@src/apps/helpers/prometheus-metrics';
import { ExpressAdapter } from '@nestjs/platform-express';
} from './helpers/prometheus-metrics';

async function bootstrap() {
sourceMapInstall();
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/board/board-api.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { AuthorizationModule } from '@modules/authorization';
import { forwardRef, Module } from '@nestjs/common';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { RoomMemberModule } from '../room-member';
import { BoardModule } from './board.module';
import {
BoardController,
Expand All @@ -12,7 +13,6 @@ import {
} from './controller';
import { BoardNodePermissionService } from './service';
import { BoardUc, CardUc, ColumnUc, ElementUc, SubmissionItemUc } from './uc';
import { RoomMemberModule } from '../room-member';

@Module({
imports: [BoardModule, LoggerModule, RoomMemberModule, forwardRef(() => AuthorizationModule)],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import { AuthGuardModule, AuthGuardOptions } from '@infra/auth-guard';
import { MongoMemoryDatabaseModule } from '@infra/database';
import { RabbitMQWrapperModule } from '@infra/rabbitmq';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ALL_ENTITIES } from '@shared/domain/entity/all-entities';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { RabbitMQWrapperModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { AuthenticationApiModule } from '../authentication/authentication-api.module';
import { AuthorizationModule } from '../authorization';
import { serverConfig } from '../server';
import { config } from './board-collaboration.config';
import { BoardWsApiModule } from './board-ws-api.module';
import { BoardModule } from './board.module';

const imports = [
CoreModule,
RabbitMQWrapperModule,
BoardModule,
AuthorizationModule,
BoardWsApiModule,
AuthGuardModule.register([AuthGuardOptions.WS_JWT]),
];

@Module({
imports: [
CoreModule,
...imports,
ConfigModule.forRoot(createConfigModuleOptions(config)),
RabbitMQWrapperModule,
MikroOrmModule.forRoot({
...defaultMikroOrmOptions,
type: 'mongo',
Expand All @@ -25,12 +36,25 @@ import { BoardModule } from './board.module';
user: DB_USERNAME,
entities: ALL_ENTITIES,
}),
BoardModule,
AuthorizationModule,
BoardWsApiModule,
AuthGuardModule.register([AuthGuardOptions.WS_JWT]),
],
providers: [],
exports: [],
})
export class BoardCollaborationModule {}

const testConfig = () => {
return { ...serverConfig(), ...config() };
};

@Module({
imports: [
...imports,
ConfigModule.forRoot(createConfigModuleOptions(testConfig)),
AuthenticationApiModule,
MongoMemoryDatabaseModule.forRoot({
...defaultMikroOrmOptions,
entities: ALL_ENTITIES,
}),
],
})
export class BoardCollaborationTestModule {}

This file was deleted.

2 changes: 1 addition & 1 deletion apps/server/src/modules/board/board-ws-api.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthorizationModule } from '@modules/authorization';
import { UserModule } from '@modules/user';
import { forwardRef, Module } from '@nestjs/common';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { RoomMemberModule } from '../room-member';
import { BoardModule } from './board.module';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/board/board.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { UserModule } from '@modules/user';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { AuthorizationModule } from '../authorization';
import { RoomMemberModule } from '../room-member';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { EntityManager } from '@mikro-orm/mongodb';
import { ServerTestModule } from '@modules/server/server.module';
import { HttpStatus, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { sanitizeRichText } from '@shared/controller';
import { sanitizeRichText } from '@shared/controller/transformer/sanitize-html.transformer';
import { InputFormat } from '@shared/domain/types';
import { cleanupCollections, courseFactory, TestApiClient, UserAndAccountTestFactory } from '@shared/testing';
import { BoardNodeEntity } from '../../repo';
import { BoardExternalReferenceType, ContentElementType } from '../../domain';
import { BoardNodeEntity } from '../../repo';
import {
cardEntityFactory,
columnBoardEntityFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';

import { MongoIoAdapter } from '@infra/socketio';
import { InputFormat } from '@shared/domain/types';
import { InputFormat } from '@shared/domain/types/input-format.types';
import { cleanupCollections, courseFactory, userFactory } from '@shared/testing';
import { getSocketApiClient, waitForEvent } from '@shared/testing/test-socket-api-client';
import { Socket } from 'socket.io-client';
import { BoardCollaborationTestModule } from '../../board-collaboration.app.module';
import { BoardExternalReferenceType, CardProps, ContentElementType } from '../../domain';
import {
cardEntityFactory,
columnBoardEntityFactory,
columnEntityFactory,
richTextElementEntityFactory,
} from '../../testing';
import { BoardExternalReferenceType, CardProps, ContentElementType } from '../../domain';
import { BoardCollaborationTestingModule } from '../../board-collaboration.testing.module';
import { BoardCollaborationGateway } from '../board-collaboration.gateway';

describe(BoardCollaborationGateway.name, () => {
Expand All @@ -25,7 +25,7 @@ describe(BoardCollaborationGateway.name, () => {

beforeAll(async () => {
const testingModule = await Test.createTestingModule({
imports: [BoardCollaborationTestingModule],
imports: [BoardCollaborationTestModule],
}).compile();
app = testingModule.createNestApplication();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ObjectId } from '@mikro-orm/mongodb';
import { Test, TestingModule } from '@nestjs/testing';
import { CourseRepo } from '@shared/repo';
import { courseFactory, groupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { RoomMemberService } from '@src/modules/room-member';
import { roomFactory } from '@src/modules/room/testing';
import { Permission, RoleName } from '@shared/domain/interface';
import { CourseRepo } from '@shared/repo/course';
import { courseFactory, groupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { GroupTypes } from '@src/modules/group';
import { RoomMemberService } from '@src/modules/room-member';
import { roomMemberFactory } from '@src/modules/room-member/testing';
import { columnFactory, columnBoardFactory } from '../../testing';
import { roomFactory } from '@src/modules/room/testing';
import { BoardExternalReferenceType, BoardRoles, UserWithBoardRoles } from '../../domain';
import { columnBoardFactory, columnFactory } from '../../testing';
import { BoardContextService } from './board-context.service';

describe(`${BoardContextService.name}`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Permission } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { RoomMemberService } from '@src/modules/room-member';
import { UserWithRoomRoles } from '@src/modules/room-member/do/room-member-authorizable.do';
import { AnyBoardNode, BoardExternalReferenceType, BoardRoles, UserWithBoardRoles } from '../../domain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StorageLocation } from '@modules/files-storage/interface';
import { UserService } from '@modules/user';
import { Injectable, InternalServerErrorException, NotImplementedException } from '@nestjs/common';
import { EntityId } from '@shared/domain/types';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { BoardExternalReference, BoardExternalReferenceType, ColumnBoard, isColumnBoard } from '../../domain';
import { BoardNodeService } from '../board-node.service';
import { BoardNodeCopyContext } from './board-node-copy-context';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/board/uc/board.uc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb';
import { Action, AuthorizationService } from '@modules/authorization';
import { Test, TestingModule } from '@nestjs/testing';
import { Permission } from '@shared/domain/interface';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { setupEntities, userFactory } from '@shared/testing';
import { courseFactory } from '@shared/testing/factory';
import { LegacyLogger } from '@src/core/logger';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/board/uc/board.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CopyStatus } from '@modules/copy-helper';
import { forwardRef, Inject, Injectable } from '@nestjs/common';
import { Permission } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LegacyLogger } from '@src/core/logger';
import { RoomMemberService } from '@src/modules/room-member';
import { CreateBoardBodyParams } from '../controller/dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Module } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { RabbitMQWrapperModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { BoardClientModule } from './common-cartridge-client/board-client';
import { CoursesClientModule } from './common-cartridge-client/course-client';
import { CommonCartridgeExportService } from './service/common-cartridge-export.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserModule } from '@modules/user';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config';
import { AccountModule } from '@modules/account';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FileEntity } from '../files/entity';
import { DeletionClient } from './deletion-client';
import { DeletionQueueConsole } from './deletion-queue.console';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { DeepMocked } from '@golevelup/ts-jest';
import { MongoMemoryDatabaseModule } from '@infra/database';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { DeletionExecutionConsole } from './deletion-execution.console';
import { DeletionExecutionTriggerResultBuilder, TriggerDeletionExecutionOptionsBuilder } from './builder';
import { DeletionExecutionUc } from './uc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ObjectId } from 'bson';
import fs from 'fs';
import { Test, TestingModule } from '@nestjs/testing';
import { MongoMemoryDatabaseModule } from '@infra/database';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { DeletionQueueConsole } from './deletion-queue.console';
import { PushDeleteRequestsOptionsBuilder } from './builder';
import { BatchDeletionUc } from './uc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RabbitMQWrapperTestModule } from '@infra/rabbitmq';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FileRecord } from './entity';
import { FilesStorageApiModule } from './files-storage-api.module';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Module } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FileRecord, FileRecordSecurityCheck } from './entity';
import { s3Config } from './files-storage.config';
import { FileRecordRepo } from './repo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@sr
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { AccountEntity } from '@src/modules/account/domain/entity/account.entity';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FwuLearningContentsController } from './controller/fwu-learning-contents.controller';
import { config, s3Config } from './fwu-learning-contents.config';
import { FwuLearningContentsUc } from './uc/fwu-learning-contents.uc';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/h5p-editor/h5p-editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { Logger } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { H5PEditorController } from './controller/h5p-editor.controller';
import { H5PContent, InstalledLibrary } from './entity';
import { authorizationClientConfig, config, s3ConfigContent, s3ConfigLibraries } from './h5p-editor.config';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ObjectId } from 'bson';
import { Test, TestingModule } from '@nestjs/testing';
import { MongoMemoryDatabaseModule } from '@infra/database';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { IdpSyncConsole } from './idp-sync-console';
import { SystemType } from './interface';
import { UsersSyncOptionsBuilder } from '../testing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { LoggerModule } from '@src/core/logger';
import { ConsoleModule } from 'nestjs-console';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { idpConsoleConfigConfig } from './idp-console.config';
import { IdpSyncConsole, SynchronizationUc } from './api';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MikroOrmModule } from '@mikro-orm/nestjs';
import { DynamicModule, Module } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ManagementModule } from './management.module';

@Module({
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/server/admin-api.server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LoggerModule } from '@src/core/logger';
import { MongoDatabaseModuleOptions, MongoMemoryDatabaseModule } from '@src/infra/database';
import { EtherpadClientModule } from '@src/infra/etherpad-client';
import { RabbitMQWrapperModule, RabbitMQWrapperTestModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { AdminApiRegistrationPinModule } from '../registration-pin/admin-api-registration-pin.module';
import { adminApiServerConfig } from './admin-api-server.config';

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/server/server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ServerConfigController, ServerController, ServerUc } from './api';
import { SERVER_CONFIG_TOKEN, serverConfig } from './server.config';

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/tldraw/tldraw-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions, DB_PASSWORD, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { config, TLDRAW_DB_URL } from './config';
import { TldrawController } from './controller';
import { TldrawDrawing } from './entities';
Expand Down
Loading

0 comments on commit 4b26336

Please sign in to comment.