Skip to content

Commit

Permalink
refactor: env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
collettemathieu committed Oct 11, 2024
1 parent 20f4ced commit a94f94a
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { PDSPAInitializePathwayCommand } from './lib/initialize/command/initialize-pathway.command';
export { PDSPAInitializePathwayCommandHandler } from './lib/initialize/command/initialize-pathway.command-handler';
export { PDSPAInitializePathwayService } from './lib/initialize/service/initialize-pathway.service';
export { PDSPA_InitializePathwayService } from './lib/initialize/service/initialize-pathway.service';
export { PDSPAIUInitializePathwayUsecase } from './lib/initialize/usecase/initialize-pathway.usecase';

export { PDSPAChangeTitlePathwayCommand } from './lib/change-title/command/change-title-pathway.command';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CommandBus } from '@nestjs/cqrs';
import type { PDSPAInitializePathwayCommand } from '../command/initialize-pathway.command';

@Injectable()
export class PDSPAInitializePathwayService {
export class PDSPA_InitializePathwayService {
constructor(private readonly commandBus: CommandBus) {}

init(pDSPAInitializePathwayCommand: PDSPAInitializePathwayCommand) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export {
PDSPIPPathwayPersistenceInfrastructureModule,
PDSPIPPersistenceDriverAuthorized,
pDSPIPPersistenceKeys,
} from './lib/persistence/pathway-persistence-infrastructure.module';
export { pDSPIPPersistenceKeys } from './lib/persistence/pathway-persistence-infrastructure.constants';
export { PDSPIPPathwayPersistenceInfrastructureModule } from './lib/persistence/pathway-persistence-infrastructure.module';
export { PDSPIPPersistenceDriverAuthorized } from './lib/persistence/pathway-persistence-infrastructure.types';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
PDSPBP_CHANGE_TITLE_PATHWAY_PERSISTENCE_PORT,
PDSPBP_INITIALIZE_PATHWAY_PERSISTENCE_PORT,
} from '@bewoak/pathway-design-server-pathway-business';
import type { Provider } from '@nestjs/common';
import { ChangeTitlePathwayInMemoryPersistence } from './change-title/in-memory/change-title-pathway-in-memory.persistence';
import { PathwayInMemoryRepository } from './common/in-memory/repositories/in-memory-pathway.repository';
import { InitializePathwayInMemoryPersistence } from './initialize/in-memory/initialize-pathway-in-memory.persistence';
import type { PDSPIPPersistenceDriverAuthorized } from './pathway-persistence-infrastructure.types';

export const persistenceProvidersMap: Record<PDSPIPPersistenceDriverAuthorized, Provider[]> = {
inMemory: [
InitializePathwayInMemoryPersistence,
{
provide: PDSPBP_INITIALIZE_PATHWAY_PERSISTENCE_PORT,
useExisting: InitializePathwayInMemoryPersistence,
},
ChangeTitlePathwayInMemoryPersistence,
{
provide: PDSPBP_CHANGE_TITLE_PATHWAY_PERSISTENCE_PORT,
useExisting: ChangeTitlePathwayInMemoryPersistence,
},
PathwayInMemoryRepository,
],
orm: [],
};

export const pDSPIPPersistenceKeys = Object.keys(persistenceProvidersMap) as [PDSPIPPersistenceDriverAuthorized];
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
import { Module, type Provider } from '@nestjs/common';
import { Module } from '@nestjs/common';

import {
PDSPBP_CHANGE_TITLE_PATHWAY_PERSISTENCE_PORT,
PDSPBP_INITIALIZE_PATHWAY_PERSISTENCE_PORT,
} from '@bewoak/pathway-design-server-pathway-business';
import { ChangeTitlePathwayInMemoryPersistence } from './change-title/in-memory/change-title-pathway-in-memory.persistence';
import { PathwayInMemoryRepository } from './common/in-memory/repositories/in-memory-pathway.repository';
import { InitializePathwayInMemoryPersistence } from './initialize/in-memory/initialize-pathway-in-memory.persistence';

const persistenceProvidersMap: Record<'inMemory', Provider[]> = {
inMemory: [
InitializePathwayInMemoryPersistence,
{
provide: PDSPBP_INITIALIZE_PATHWAY_PERSISTENCE_PORT,
useExisting: InitializePathwayInMemoryPersistence,
},
ChangeTitlePathwayInMemoryPersistence,
{
provide: PDSPBP_CHANGE_TITLE_PATHWAY_PERSISTENCE_PORT,
useExisting: ChangeTitlePathwayInMemoryPersistence,
},
PathwayInMemoryRepository,
],
};

export const pDSPIPPersistenceKeys = Object.keys(persistenceProvidersMap) as [PDSPIPPersistenceDriverAuthorized];

export type PDSPIPPersistenceDriverAuthorized = keyof typeof persistenceProvidersMap;
import { persistenceProvidersMap } from './pathway-persistence-infrastructure.constants';
import type { PDSPIPPersistenceDriverAuthorized } from './pathway-persistence-infrastructure.types';

@Module({})
// biome-ignore lint/complexity/noStaticOnlyClass: not pertinent here because this is a module
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type PDSPIPPersistenceDriverAuthorized = 'inMemory' | 'orm';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// biome-ignore lint/style/useImportType: <explanation>
import { PDSPAInitializePathwayCommand, PDSPAInitializePathwayService } from '@bewoak/pathway-design-server-pathway-application';
import { PDSPAInitializePathwayCommand, PDSPA_InitializePathwayService } from '@bewoak/pathway-design-server-pathway-application';
import { Body, Controller, HttpStatus, Post, UsePipes, ValidationPipe } from '@nestjs/common';
import { ApiBadRequestResponse, ApiCreatedResponse, ApiTags } from '@nestjs/swagger';
// biome-ignore lint/style/useImportType: <explanation>
Expand All @@ -17,7 +17,7 @@ import { InitializedPathwayResponseBodyDto } from '../dtos/response/body/respons
path: 'pathway',
})
export class InitializePathwayController {
constructor(private readonly pDSPAInitializePathwayService: PDSPAInitializePathwayService) {}
constructor(private readonly pDSPAInitializePathwayService: PDSPA_InitializePathwayService) {}

@Post('init')
@ApiCreatedResponse({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
PDSPAIUInitializePathwayUsecase,
PDSPAInitializePathwayCommandHandler,
PDSPAInitializePathwayService,
PDSPA_InitializePathwayService,
} from '@bewoak/pathway-design-server-pathway-application';
import { type DynamicModule, Module, type Type } from '@nestjs/common';
import { InitializePathwayController } from './controller/initialize-pathway.controller';

@Module({
controllers: [InitializePathwayController],
providers: [PDSPAInitializePathwayCommandHandler, PDSPAInitializePathwayService, PDSPAIUInitializePathwayUsecase],
exports: [PDSPAInitializePathwayService],
providers: [PDSPAInitializePathwayCommandHandler, PDSPA_InitializePathwayService, PDSPAIUInitializePathwayUsecase],
exports: [PDSPA_InitializePathwayService],
})
// biome-ignore lint/complexity/noStaticOnlyClass: not pertinent here because this is a module
export class PDSPIAInitializePathwayInterfaceAdaptersModule {
Expand Down
8 changes: 3 additions & 5 deletions libs/pathway-design/server/pathway/presenters/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export {
PDSPPPathwayPresentersModule,
PDSPPPresenterDriverAuthorized,
pDSPPPresenterKeys,
} from './lib/pathway-presenters.module';
export { pDSPPPresenterKeys } from './lib/pathway-presenters.constants';
export { PDSPPPathwayPresentersModule } from './lib/pathway-presenters.module';
export { PDSPPPresenterDriverAuthorized } from './lib/pathway-presenters.types';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { PDSPPPresenterDriverAuthorized } from './pathway-presenters.types';
import { ToJsonPathwayPresenterModule } from './toJson/to-json-pathway-presenter.module';

export const presenterModuleMap: Record<PDSPPPresenterDriverAuthorized, typeof ToJsonPathwayPresenterModule> = {
toJson: ToJsonPathwayPresenterModule,
};

export const pDSPPPresenterKeys = Object.keys(presenterModuleMap) as [PDSPPPresenterDriverAuthorized];
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { Module } from '@nestjs/common';
import { ToJsonPathwayPresenterModule } from './toJson/to-json-pathway-presenter.module';

const presenterModuleMap: Record<'toJson', typeof ToJsonPathwayPresenterModule> = {
toJson: ToJsonPathwayPresenterModule,
};

export const pDSPPPresenterKeys = Object.keys(presenterModuleMap) as [PDSPPPresenterDriverAuthorized];

export type PDSPPPresenterDriverAuthorized = keyof typeof presenterModuleMap;
import { presenterModuleMap } from './pathway-presenters.constants';
import type { PDSPPPresenterDriverAuthorized } from './pathway-presenters.types';

@Module({})
// biome-ignore lint/complexity/noStaticOnlyClass: not pertinent here because this is a module
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type PDSPPPresenterDriverAuthorized = 'toJson';

0 comments on commit a94f94a

Please sign in to comment.