From 17eee456b3e2592f0cef05fb0917bef075addbeb Mon Sep 17 00:00:00 2001 From: Mathieu Collette Date: Wed, 4 Sep 2024 17:03:00 +0200 Subject: [PATCH] fix: validationPipe --- .vscode/settings.json | 7 ++++++- .../command/initialize-pathway.command-handler.ts | 5 +++-- .../service/initialize-pathway.service.ts | 5 +++-- ...initialize-pathway-in-memory.persistence.spec.ts | 2 +- .../controller/initialize-pathway.controller.ts | 13 +++++++++---- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e0c641e7..2ece1814 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,5 +13,10 @@ "source.organizeImports.biome": "explicit" }, "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.formatOnSave": true, + "workbench.colorCustomizations": { + "tree.indentGuidesStroke": "#05ef3c" + }, + "workbench.tree.indent": 15, + "workbench.tree.renderIndentGuides": "always" } \ No newline at end of file diff --git a/libs/pathway-design/server/pathway/application/src/lib/initialize/command/initialize-pathway.command-handler.ts b/libs/pathway-design/server/pathway/application/src/lib/initialize/command/initialize-pathway.command-handler.ts index a6035bad..81a9279b 100644 --- a/libs/pathway-design/server/pathway/application/src/lib/initialize/command/initialize-pathway.command-handler.ts +++ b/libs/pathway-design/server/pathway/application/src/lib/initialize/command/initialize-pathway.command-handler.ts @@ -6,12 +6,14 @@ import { } from '@bewoak/pathway-design-server-pathway-business'; import { Inject } from '@nestjs/common'; +// biome-ignore lint/style/useImportType: import { CommandHandler, EventPublisher, type ICommandHandler, } from '@nestjs/cqrs'; +// biome-ignore lint/style/useImportType: import { PDSPAIUInitializePathwayUsecase } from '../usecase/initialize-pathway.usecase'; import { PDSPAInitializePathwayCommand } from './initialize-pathway.command'; @@ -20,13 +22,12 @@ export class PDSPAInitializePathwayCommandHandler implements ICommandHandler { constructor( - @Inject(PDSPAIUInitializePathwayUsecase) private readonly pDSPAIUInitializePathwayUsecase: PDSPAIUInitializePathwayUsecase, @Inject(PDSPBP_INITIALIZE_PATHWAY_PERSISTENCE_PORT) private readonly pDSPBPInitializePathwayPersistencePort: PDSPBPInitializePathwayPersistencePort, @Inject(PDSPBP_PATHWAY_PRESENTER_PORT) private readonly pDSPBPPathwayPresenterPort: PDSPBPPathwayPresenterPort, - @Inject(EventPublisher) private readonly eventPublisher: EventPublisher + private readonly eventPublisher: EventPublisher ) {} execute(pDSPAInitializePathwayCommand: PDSPAInitializePathwayCommand) { diff --git a/libs/pathway-design/server/pathway/application/src/lib/initialize/service/initialize-pathway.service.ts b/libs/pathway-design/server/pathway/application/src/lib/initialize/service/initialize-pathway.service.ts index d654d66f..b32a27e9 100644 --- a/libs/pathway-design/server/pathway/application/src/lib/initialize/service/initialize-pathway.service.ts +++ b/libs/pathway-design/server/pathway/application/src/lib/initialize/service/initialize-pathway.service.ts @@ -1,11 +1,12 @@ import type { PDSPBPPathwayPresenters } from '@bewoak/pathway-design-server-pathway-business'; -import { Inject, Injectable } from '@nestjs/common'; +import { Injectable } from '@nestjs/common'; +// biome-ignore lint/style/useImportType: import { CommandBus } from '@nestjs/cqrs'; import type { PDSPAInitializePathwayCommand } from '../command/initialize-pathway.command'; @Injectable() export class PDSPAInitializePathwayService { - constructor(@Inject(CommandBus) private readonly commandBus: CommandBus) {} + constructor(private readonly commandBus: CommandBus) {} init(pDSPAInitializePathwayCommand: PDSPAInitializePathwayCommand) { return this.commandBus.execute< diff --git a/libs/pathway-design/server/pathway/infrastructure/src/lib/persistence/initialize/in-memory/initialize-pathway-in-memory.persistence.spec.ts b/libs/pathway-design/server/pathway/infrastructure/src/lib/persistence/initialize/in-memory/initialize-pathway-in-memory.persistence.spec.ts index 1f77f054..77e0f724 100644 --- a/libs/pathway-design/server/pathway/infrastructure/src/lib/persistence/initialize/in-memory/initialize-pathway-in-memory.persistence.spec.ts +++ b/libs/pathway-design/server/pathway/infrastructure/src/lib/persistence/initialize/in-memory/initialize-pathway-in-memory.persistence.spec.ts @@ -1,10 +1,10 @@ -import { beforeEach, describe, expect, spyOn, test } from 'bun:test'; import { type PDSPBEPathwayEntity, pDSPBFPathwayFactory, } from '@bewoak/pathway-design-server-pathway-business'; import { NotFoundException } from '@nestjs/common'; import { Test } from '@nestjs/testing'; +import { beforeEach, describe, expect, spyOn, test } from 'bun:test'; import { PathwayInMemoryRepository } from '../../common/in-memory/repositories/in-memory-pathway.repository'; import { InitializePathwayInMemoryPersistence } from './initialize-pathway-in-memory.persistence'; diff --git a/libs/pathway-design/server/pathway/interface-adapters/src/lib/initialize/controller/initialize-pathway.controller.ts b/libs/pathway-design/server/pathway/interface-adapters/src/lib/initialize/controller/initialize-pathway.controller.ts index 22690f57..c983644f 100644 --- a/libs/pathway-design/server/pathway/interface-adapters/src/lib/initialize/controller/initialize-pathway.controller.ts +++ b/libs/pathway-design/server/pathway/interface-adapters/src/lib/initialize/controller/initialize-pathway.controller.ts @@ -1,3 +1,4 @@ +// biome-ignore lint/style/useImportType: import { PDSPAInitializePathwayCommand, PDSPAInitializePathwayService, @@ -5,21 +6,25 @@ import { import { Body, Controller, - Inject, Post, UsePipes, ValidationPipe, } from '@nestjs/common'; -import type { InitializePathwayRequestBodyDto } from '../dtos/request/body/index.dto'; +// biome-ignore lint/style/useImportType: +import { InitializePathwayRequestBodyDto } from '../dtos/request/body/index.dto'; import type { InitializedPathwayResponseBodyDto } from '../dtos/response/body/index.dto'; -@UsePipes(new ValidationPipe()) +@UsePipes( + new ValidationPipe({ + whitelist: true, + forbidNonWhitelisted: true, + }) +) @Controller({ path: 'pathway', }) export class InitializePathwayController { constructor( - @Inject(PDSPAInitializePathwayService) private readonly pDSPAInitializePathwayService: PDSPAInitializePathwayService ) {}