Skip to content

Commit

Permalink
Fix idp-console.module configs with dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
CeEv committed Nov 18, 2024
1 parent 0a72ea4 commit 35afb4b
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/server/src/apps/idp-console.app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* istanbul ignore file */
import { IdpConsoleModule } from '@modules/idp-console';
import { IdpConsoleModule } from '@modules/idp-console/idp-console.app.module';
import { BootstrapConsole } from 'nestjs-console';

async function run() {
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/infra/console/console-writer.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ConsoleWriterConfig {}
3 changes: 2 additions & 1 deletion apps/server/src/infra/console/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './console-writer';
export { ConsoleWriterModule, ConsoleWriterService } from './console-writer';
export { ConsoleWriterConfig } from './console-writer.config';
9 changes: 8 additions & 1 deletion apps/server/src/infra/rabbitmq/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
export * from './error.mapper';
export * from './exchange';
export * from './rabbitmq.config';
export {
RabbitMqConfig,
FilesPreviewExchange,
FilesStorageExchange,
MailSendExchange,
AntivirusExchange,
RabbitMqURI,
} from './rabbitmq.config';
export * from './rabbitmq.module';
export * from './rpc-message';
export * from './rpc-message-producer';
4 changes: 4 additions & 0 deletions apps/server/src/infra/rabbitmq/rabbitmq.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Configuration } from '@hpi-schul-cloud/commons/lib';

// should be move to config interface and added reading on places that use the module
export const FilesPreviewExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;
export const FilesStorageExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;
export const MailSendExchange = Configuration.get('MAIL_SEND_EXCHANGE') as string;
export const AntivirusExchange = Configuration.get('ANTIVIRUS_EXCHANGE') as string;
export const RabbitMqURI = Configuration.get('RABBITMQ_URI') as string;

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RabbitMqConfig {}
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { ConsoleWriterModule } from '@infra/console';
import { RabbitMQWrapperModule } from '@infra/rabbitmq';
import { SchulconnexClientModule } from '@infra/schulconnex-client/schulconnex-client.module';
import { SchulconnexClientModule } from '@infra/schulconnex-client/schulconnex-client.module'; // TODO: Fix me!
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { AccountModule } from '@modules/account';
import { SynchronizationEntity, SynchronizationModule } from '@modules/synchronization';
import { UserModule } from '@modules/user';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
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 { IdpSyncConsole } from './idp-sync-console';
import { SynchronizationUc } from './uc';
import { idpConsoleConfigConfig } from './idp-console.config';

@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
ConfigModule.forRoot(createConfigModuleOptions(idpConsoleConfigConfig)),
SchulconnexClientModule.registerAsync(),
SynchronizationModule,
MikroOrmModule.forRoot({
Expand Down
42 changes: 42 additions & 0 deletions apps/server/src/modules/idp-console/idp-console.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ConsoleWriterConfig } from '@infra/console';
import { LoggerConfig } from '@src/core/logger';
import { AccountConfig } from '@modules/account';
import { UserConfig } from '@modules/user';
import { SynchronizationConfig } from '@modules/synchronization';
import { SchulconnexClientConfig } from '@infra/schulconnex-client';
import { Configuration } from '@hpi-schul-cloud/commons';
import { LanguageType } from '@shared/domain/interface';
import { RabbitMqConfig } from '@src/infra/rabbitmq';

interface IdpConsoleConfig
extends ConsoleWriterConfig,
RabbitMqConfig,
LoggerConfig,
AccountConfig,
UserConfig,
SynchronizationConfig,
SchulconnexClientConfig {
SYNCHRONIZATION_CHUNK: number;
}

const config: IdpConsoleConfig = {
SYNCHRONIZATION_CHUNK: Configuration.get('SYNCHRONIZATION_CHUNK') as number,
NEST_LOG_LEVEL: Configuration.get('NEST_LOG_LEVEL') as string,
EXIT_ON_ERROR: Configuration.get('EXIT_ON_ERROR') as boolean,
LOGIN_BLOCK_TIME: Configuration.get('LOGIN_BLOCK_TIME') as number,
TEACHER_STUDENT_VISIBILITY__IS_CONFIGURABLE: Configuration.get(
'TEACHER_STUDENT_VISIBILITY__IS_CONFIGURABLE'
) as boolean,
FEATURE_IDENTITY_MANAGEMENT_LOGIN_ENABLED: Configuration.get('FEATURE_IDENTITY_MANAGEMENT_LOGIN_ENABLED') as boolean,
FEATURE_IDENTITY_MANAGEMENT_STORE_ENABLED: Configuration.get('FEATURE_IDENTITY_MANAGEMENT_STORE_ENABLED') as boolean,
AVAILABLE_LANGUAGES: (Configuration.get('I18N__AVAILABLE_LANGUAGES') as string).split(',') as LanguageType[],
TEACHER_VISIBILITY_FOR_EXTERNAL_TEAM_INVITATION: '',
SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS: Configuration.get(
'SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS'
) as number,
SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS: Configuration.get(
'SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS'
) as number,
};

export const idpConsoleConfigConfig = () => config;
3 changes: 1 addition & 2 deletions apps/server/src/modules/idp-console/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './idp-console.module';
export * from './interface';
export { UsersSyncOptions, SystemType } from './interface'; // TODO: Why exports are needed?
1 change: 0 additions & 1 deletion apps/server/src/modules/idp-console/interface/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './system-type.enum';
export * from './users-sync-options.interface';
export * from './synchronization.config';

This file was deleted.

5 changes: 2 additions & 3 deletions apps/server/src/modules/server/server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { AuthenticationConfig } from '@modules/authentication';
import type { BoardConfig, MediaBoardConfig } from '@modules/board';
import type { CollaborativeTextEditorConfig } from '@modules/collaborative-text-editor';
import type { FilesStorageClientConfig } from '@modules/files-storage-client';
import { SynchronizationConfig } from '@modules/idp-console';
import type { LearnroomConfig } from '@modules/learnroom';
import type { LessonConfig } from '@modules/lesson';
import { OauthConfig } from '@modules/oauth';
Expand Down Expand Up @@ -65,7 +64,7 @@ export interface ServerConfig
SharingConfig,
UserImportConfig,
SchulconnexClientConfig,
SynchronizationConfig,
// SynchronizationConfig,
CollaborativeTextEditorConfig,
ProvisioningConfig,
RoomConfig,
Expand Down Expand Up @@ -217,7 +216,7 @@ const config: ServerConfig = {
FEATURE_IDENTITY_MANAGEMENT_LOGIN_ENABLED: Configuration.get('FEATURE_IDENTITY_MANAGEMENT_LOGIN_ENABLED') as boolean,
FEATURE_TSP_SYNC_ENABLED: Configuration.get('FEATURE_TSP_SYNC_ENABLED') as boolean,
STUDENT_TEAM_CREATION: Configuration.get('STUDENT_TEAM_CREATION') as string,
SYNCHRONIZATION_CHUNK: Configuration.get('SYNCHRONIZATION_CHUNK') as number,
// SYNCHRONIZATION_CHUNK: Configuration.get('SYNCHRONIZATION_CHUNK') as number,
// parse [<description>:]<token>,[<description>:]<token>... and discard description
BLOCKLIST_OF_EMAIL_DOMAINS: (Configuration.get('BLOCKLIST_OF_EMAIL_DOMAINS') as string)
.split(',')
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/modules/synchronization/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { SynchronizationModule } from './synchronization.module';
export * from './domain';
export * from './domain'; // TODO: Fix me!
export { SynchronizationEntity, SynchronizationRepo } from './repo';
export { SynchronizationConfig } from './synchronization.config';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SynchronizationConfig {}

0 comments on commit 35afb4b

Please sign in to comment.