Skip to content

Commit

Permalink
fix: validationPipe
Browse files Browse the repository at this point in the history
  • Loading branch information
collettemathieu committed Sep 4, 2024
1 parent 2760aeb commit 17eee45
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {
} from '@bewoak/pathway-design-server-pathway-business';

import { Inject } from '@nestjs/common';
// biome-ignore lint/style/useImportType: <explanation>
import {
CommandHandler,
EventPublisher,
type ICommandHandler,
} from '@nestjs/cqrs';

// biome-ignore lint/style/useImportType: <explanation>
import { PDSPAIUInitializePathwayUsecase } from '../usecase/initialize-pathway.usecase';
import { PDSPAInitializePathwayCommand } from './initialize-pathway.command';

Expand All @@ -20,13 +22,12 @@ export class PDSPAInitializePathwayCommandHandler
implements ICommandHandler<PDSPAInitializePathwayCommand>
{
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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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: <explanation>
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<
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
// biome-ignore lint/style/useImportType: <explanation>
import {
PDSPAInitializePathwayCommand,
PDSPAInitializePathwayService,
} from '@bewoak/pathway-design-server-pathway-application';
import {
Body,
Controller,
Inject,
Post,
UsePipes,
ValidationPipe,
} from '@nestjs/common';
import type { InitializePathwayRequestBodyDto } from '../dtos/request/body/index.dto';
// biome-ignore lint/style/useImportType: <explanation>
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
) {}

Expand Down

0 comments on commit 17eee45

Please sign in to comment.