Skip to content

Ajoute un décorateur @AuditId pour vérifier l’existence d’un audit#1477

Open
hissalht wants to merge 5 commits intomainfrom
refactor/audit-exists
Open

Ajoute un décorateur @AuditId pour vérifier l’existence d’un audit#1477
hissalht wants to merge 5 commits intomainfrom
refactor/audit-exists

Conversation

@hissalht
Copy link
Copy Markdown
Collaborator

@hissalht hissalht commented Apr 18, 2026

Similaire au décorateur @Param('uniqueId'), @AuditId vérifie aussi l’existence de l’audit en base (pas besoin de faire le check dans la méthode) et documente les réponses 404 et 410 (sur swagger) des routes où il est présent

Avant :

class Controller {
  /** Update an audit data in the database. */
  @Put("/:uniqueId")
  @ApiOkResponse({ description: "The audit has been successfully updated", type: AuditDto })
  @ApiNotFoundResponse({ description: "The audit does not exist." })
  @ApiGoneResponse({ description: "The audit has been previously deleted." })
  async updateAudit(
    @Param("uniqueId") uniqueId: string,
    @Body() body: UpdateAuditDto
  ): Promise<AuditDto> {
    const audit = await this.auditService.updateAudit(uniqueId, body);

    if (!audit) {
      await this.sendAuditNotFoundStatus(uniqueId);
    }

    return audit;
  }
}

Après :

class Controller {
  /** Update an audit data in the database. */
  @Put("/:uniqueId")
  @ApiOkResponse({ description: "The audit has been successfully updated", type: AuditDto })
  async updateAudit(
    @AuditId() uniqueId: string,
    @Body() body: UpdateAuditDto
  ): Promise<AuditDto> {
    return this.auditService.updateAudit(uniqueId, body);
  }
}

@hissalht hissalht changed the title Ajoute un décorateur @AuditId pour répupére Ajoute un décorateur @AuditId pour vérifier l’existence d’un audit Apr 18, 2026
@hissalht hissalht temporarily deployed to ara-refactor-audit-exis-msnzmu April 18, 2026 18:28 Inactive
@hissalht hissalht added Nettoyage DX Concerne l'expérience développeur labels Apr 18, 2026
@AdrienMuzyczka AdrienMuzyczka added this to the 39 - 8/04 milestone Apr 22, 2026
Comment thread confiture-rest-api/src/audits/audit.pipe.ts Outdated
function methodDecoratorToParamDecorator(
decorator: MethodDecorator
): ParameterDecorator {
return (target: object, propertyKey: string) =>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai une erreur TS ici :

Type '(target: object, propertyKey: string) => void | TypedPropertyDescriptor<any>' is not assignable to type 'ParameterDecorator'.
  Types of parameters 'propertyKey' and 'propertyKey' are incompatible.
    Type 'string | symbol' is not assignable to type 'string'.
      Type 'symbol' is not assignable to type 'string'.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je l’ai pas en local, tu as bien yarn install ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DX Concerne l'expérience développeur Nettoyage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants