Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Conversation

@Juknum
Copy link
Member

@Juknum Juknum commented Nov 2, 2023

The goal here is to remove usage of zod to use NestJS DTO validation

Changed

  • Remove zod usage in all controllers to fully use NestJS DTO's
  • Remove Entities classes usage in controllers in favor of DTOs; Huge refactoring of types declarations in the submodule, see :
  • Renamed src/_mixin to src/base as it makes more sense.
  • ImagesService is now a child of FilesService

Added

  • Reduced boilerplate of decorators
    • Introduce ApiNotOkResponse that easily merge all 400 responses into 1 decorator (instead of 4)
    • Introduce ApiUploadFile that merge 3 decorators into 1
    • Introduce ApiDownloadFile which is a disguised ApiOkResponse with the data content modified to application/octet-stream to match NestJS Streamable file system.
    • Added ApiForbiddenResponse and ApiUnauthorizedResponse to GuardPermissions decorators as they always comes together
  • Added i18nForbiddenException, i18nBadRequestException, i18nNotFoundException and i18nUnauthorizedException which enhance base NestJS https exceptions to add i18n support to it.
  • Added a lot of custom class-validators decorators to pre-translate & adapt validations steps for our needs (such as i18nIsEmail() which verify for blacklisted hosts/emails) (this also prevent boilerplate in some cases).

Removed

  • TranslateService removed as it was only used for errors/success messages which are now directly translated using i18n... exceptions.
  • FilesService.WriteOnDiskAsImage() as ImagesService now inherits from FilesService and super the FilesService.WriteOnDisk() method.

Fixed

  • Verify user.verified instead of user.email_verified in AuthService.validateUser()

@Juknum Juknum self-assigned this Nov 2, 2023
@Juknum Juknum requested a review from TheoDurr November 2, 2023 01:52
@Juknum Juknum added type: feature The issue is a request for new functionality including changes, enhancements, refactors, etc type: enhancement Improvement of an existing feature, which can potentially change its operation and removed type: feature The issue is a request for new functionality including changes, enhancements, refactors, etc labels Nov 2, 2023
@Juknum Juknum added this to the v1.0.0 milestone Nov 2, 2023
@Juknum Juknum changed the base branch from main to develop November 2, 2023 01:53
@Juknum Juknum requested a review from a team November 2, 2023 01:58
@Juknum Juknum added the status: pending The issue is waiting to be approved label Nov 2, 2023
@Juknum Juknum marked this pull request as ready for review November 7, 2023 17:34
@Juknum Juknum added status: pending discussion The issue or pull request needs more discussion before it can be closed or merged and removed status: pending The issue is waiting to be approved labels Nov 7, 2023
@Juknum Juknum merged commit 056357d into develop Nov 9, 2023
@Juknum Juknum deleted the fix/dto-validation branch November 9, 2023 15:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status: pending discussion The issue or pull request needs more discussion before it can be closed or merged type: enhancement Improvement of an existing feature, which can potentially change its operation

Projects

Status: 🌟 Deploy to prod

Development

Successfully merging this pull request may close these issues.

3 participants