Skip to content

Commit

Permalink
Merge branch 'main' into EW-977
Browse files Browse the repository at this point in the history
  • Loading branch information
MajedAlaitwniCap authored Jan 16, 2025
2 parents f43583d + a9f3797 commit bd1be92
Show file tree
Hide file tree
Showing 40 changed files with 94 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* istanbul ignore file */
/* eslint-disable promise/always-return */
import { BootstrapConsole } from 'nestjs-console';
import { ServerConsoleModule } from './console.module';
import { ServerConsoleModule } from '../modules/server-console/server-console.app.module';

/**
* The console is starting the application wrapped into commander.
Expand Down
12 changes: 0 additions & 12 deletions apps/server/src/config/database.config.ts

This file was deleted.

2 changes: 0 additions & 2 deletions apps/server/src/config/index.ts

This file was deleted.

6 changes: 3 additions & 3 deletions apps/server/src/config/mikro-orm-cli.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs/typings';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { FileEntity } from '@modules/files/entity';
import { FileRecord } from '@modules/files-storage/entity';
import { FileEntity } from '@modules/files/entity';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import path from 'path';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from './index';

const migrationsPath = path.resolve(__dirname, '..', 'migrations', 'mikro-orm');

Expand Down
13 changes: 13 additions & 0 deletions apps/server/src/imports-from-feathers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable import/extensions */
import globals = require('../../../config/globals');

export { BruteForcePrevention } from '../../../src/errors/index.js';
export {
addTokenToWhitelist,
Expand All @@ -14,3 +16,14 @@ export type JwtRedisData = {
privateDevice: boolean;
expirationInSeconds: number;
};

interface GlobalConstants {
DB_URL: string;
DB_PASSWORD?: string;
DB_USERNAME?: string;
}

const usedGlobals: GlobalConstants = globals;

/** Database URL */
export const { DB_URL, DB_PASSWORD, DB_USERNAME } = usedGlobals;
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { RabbitMQWrapperModule } from '@infra/rabbitmq';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
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 { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import { AuthorizationModule } from '../authorization';
import { serverConfig } from '../server';
import { config } from './board-collaboration.config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AuthorizationClientModule } from '@infra/authorization-client';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { CoreModule } from '@src/core';
import { authorizationClientConfig } from '../files-storage/files-storage.config';
import { config } from './common-cartridge.config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import { RabbitMQWrapperModule } from '@src/infra/rabbitmq';
import { BoardClientModule } from './common-cartridge-client/board-client';
import { CardClientModule } from './common-cartridge-client/card-client/card-client.module';
import { LessonClientModule } from './common-cartridge-client/lesson-client/lesson-client.module';
import { CourseRoomsModule } from './common-cartridge-client/room-client';
import { CommonCartridgeExportService, CommonCartridgeImportService } from './service';
import { CommonCartridgeUc } from './uc/common-cartridge.uc';
import { CommonCartridgeExportMapper } from './service/common-cartridge.mapper';
import { CommonCartridgeUc } from './uc/common-cartridge.uc';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { Module } from '@nestjs/common';
import { ConsoleModule } from 'nestjs-console';
import { ConfigModule } from '@nestjs/config';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { HttpModule } from '@nestjs/axios';
import { ConsoleWriterModule } from '@infra/console';
import { UserModule } from '@modules/user';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { AccountModule } from '@modules/account';
import { UserModule } from '@modules/user';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import { ConsoleModule } from 'nestjs-console';
import { FileEntity } from '../files/entity';
import { DeletionClient } from './deletion-client';
import { DeletionQueueConsole } from './deletion-queue.console';
import { BatchDeletionUc, DeletionExecutionUc } from './uc';
import { BatchDeletionService } from './services';
import { DeletionExecutionConsole } from './deletion-execution.console';
import { DeletionQueueConsole } from './deletion-queue.console';
import { deletionConsoleConfig } from './deletion.config';
import { BatchDeletionService } from './services';
import { BatchDeletionUc, DeletionExecutionUc } from './uc';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MikroORM } from '@mikro-orm/core';
import { ConfigModule } from '@nestjs/config';
import { EventBus } from '@nestjs/cqrs';
import { Test, TestingModule } from '@nestjs/testing';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { LegacyLogger } from '@src/core/logger';
import { setupEntities } from '@testing/setup-entities';
import { ObjectId } from 'bson';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ConfigModule } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { setupEntities } from '@testing/setup-entities';
import { ObjectId } from 'bson';
import { DeletionRequestRepo } from '../../repo';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PreviewGeneratorConsumerModule } from '@infra/preview-generator';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { CoreModule } from '@src/core';
import { config, defaultConfig, s3Config } from './files-storage.config';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { FilesStorageConsumer } from './controller';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AuthorizationClientModule } from '@infra/authorization-client';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { CoreModule } from '@src/core';
import { FileSecurityController, FilesStorageConfigController, FilesStorageController } from './controller';
import { authorizationClientConfig, config } from './files-storage.config';
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/files-storage/files-storage.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { RabbitMQWrapperModule } from '@infra/rabbitmq';
import { S3ClientModule } from '@infra/s3-client';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
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/defaultMikroOrmOptions';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
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 @@ -8,8 +8,8 @@ import { SystemEntity } from '@modules/system/entity';
import { HttpModule } from '@nestjs/axios';
import { DynamicModule, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
import { Role, SchoolEntity, SchoolYearEntity, User } from '@shared/domain/entity';
import { createConfigModuleOptions } from '@src/config';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { AccountEntity } from '@src/modules/account/domain/entity/account.entity';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { SystemEntity } from '@modules/system/entity';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { Role, SchoolEntity, SchoolYearEntity, User } 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 { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import { AccountEntity } from '@src/modules/account/domain/entity/account.entity';
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
5 changes: 3 additions & 2 deletions apps/server/src/modules/h5p-editor/h5p-editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { MikroOrmModule } from '@mikro-orm/nestjs';
import { UserModule } from '@modules/user';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
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/defaultMikroOrmOptions';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
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,11 +1,11 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { RabbitMQWrapperModule } from '@infra/rabbitmq';
import { S3ClientModule } from '@infra/s3-client';
import { createConfigModuleOptions } from '@src/config';
import { H5PEditorModule, s3ConfigContent, s3ConfigLibraries } from '@modules/h5p-editor';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
import { CoreModule } from '@src/core';
import { Logger } from '@src/core/logger';
import { H5PEditorModule, s3ConfigContent, s3ConfigLibraries } from '@modules/h5p-editor';
import { H5PLibraryManagementService, h5PLibraryManagementConfig } from './service';

const imports = [
Expand Down
7 changes: 4 additions & 3 deletions apps/server/src/modules/idp-console/idp-console.app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { SynchronizationEntity, SynchronizationModule } from '@modules/synchroni
import { UserModule } from '@modules/user';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
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 { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import { ConsoleModule } from 'nestjs-console';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { idpConsoleConfigConfig } from './idp-console.config';
import { IdpSyncConsole, SynchronizationUc } from './api';
import { idpConsoleConfigConfig } from './idp-console.config';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Module } from '@nestjs/common';

import { MongoMemoryDatabaseModule } from '@infra/database';
import { HealthApiModule, HealthEntities } from '@src/modules/health';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { HealthApiModule, HealthEntities } from '@modules/health';
import { serverConfig } from '@modules/server';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';

/**
* Internal server module used for testing.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Module } from '@nestjs/common';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';

import { DB_URL, DB_USERNAME, DB_PASSWORD, createConfigModuleOptions } from '@src/config';
import { HealthApiModule, HealthEntities } from '@src/modules/health';
import { ConfigModule } from '@nestjs/config';
import { serverConfig } from '@modules/server';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import { HealthApiModule, HealthEntities } from '@src/modules/health';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { MongoMemoryDatabaseModule } from '@infra/database';
import { MongoDatabaseModuleOptions } from '@infra/database/mongo-memory-database/types'; // Fix me!!
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/defaultMikroOrmOptions';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/imports-from-feathers';
import { ManagementModule } from './management.module';

@Module({
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/management/management.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { ConsoleWriterService } from '@infra/console';
import { DatabaseManagementModule, DatabaseManagementService } from '@infra/database';
import { EncryptionModule } from '@infra/encryption';
import { FeathersModule } from '@infra/feathers';
import { FileSystemModule } from '@infra/file-system';
import { KeycloakConfigurationModule } from '@infra/identity-management/keycloak-configuration/keycloak-configuration.module';
import { serverConfig } from '@modules/server';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { LoggerModule } from '@src/core/logger';
import { FeathersModule } from '@infra/feathers';
import { DatabaseManagementConsole } from './console/database-management.console';
import { DatabaseManagementController } from './controller/database-management.controller';
import { BsonConverter } from './converter/bson.converter';
Expand Down
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 { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { createConfigModuleOptions } from '@shared/common';
import { LoggerModule } from '@src/core/logger';
import metaTagExtractorConfig from './meta-tag-extractor.config';
import { MetaTagExtractorService } from './service';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { INestApplicationContext } from '@nestjs/common';
import { ConsoleWriterService } from '@infra/console';
import { ServerConsoleModule } from '@src/console/console.module';
import { ServerConsoleModule } from '@modules/server-console/server-console.app.module';
import { INestApplicationContext } from '@nestjs/common';
import { CommanderError } from 'commander';
import { BootstrapConsole, ConsoleService } from 'nestjs-console';
import { TestBootstrapConsole, execute } from './test-bootstrap.console';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ServerConsoleModule } from '@modules/server-console/server-console.app.module';
import { INestApplicationContext } from '@nestjs/common';
import { ServerConsoleModule } from '@src/console/console.module';
import { CommanderError } from 'commander';
import { BootstrapConsole, ConsoleService } from 'nestjs-console';
import { execute, TestBootstrapConsole } from './test-bootstrap.console';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { INestApplicationContext } from '@nestjs/common';

import { BootstrapConsole, ConsoleService } from 'nestjs-console';
import { ServerConsoleModule } from '@src/console/console.module';
import { ConsoleWriterService } from '@infra/console';
import { ServerConsoleModule } from '@modules/server-console/server-console.app.module';
import { BootstrapConsole, ConsoleService } from 'nestjs-console';
import { execute, TestBootstrapConsole } from './test-bootstrap.console';

describe('ServerConsole (API)', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMock } from '@golevelup/ts-jest';
import { Test, TestingModule } from '@nestjs/testing';
import { ConsoleWriterService } from '@infra/console';
import { DatabaseManagementUc } from '@modules/management/uc/database-management.uc';
import { Test, TestingModule } from '@nestjs/testing';
import { AbstractBootstrapConsole, BootstrapConsole } from 'nestjs-console';

export class TestBootstrapConsole extends AbstractBootstrapConsole<TestingModule> {
Expand All @@ -18,7 +18,7 @@ export class TestBootstrapConsole extends AbstractBootstrapConsole<TestingModule
}

export const execute = async (bootstrap: BootstrapConsole, args: string[]): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const commandResponse = await bootstrap.boot([process.argv0, 'console', ...args]);
await bootstrap.boot([process.argv0, 'console', ...args]);

return Promise.resolve();
};
Loading

0 comments on commit bd1be92

Please sign in to comment.