Skip to content

[LOCKLITE-132] Refactor register and login API routes#72

Merged
vbetsch merged 27 commits intodevelopfrom
api/refactor/132-register-login
Aug 5, 2025
Merged

[LOCKLITE-132] Refactor register and login API routes#72
vbetsch merged 27 commits intodevelopfrom
api/refactor/132-register-login

Conversation

@vbetsch
Copy link
Owner

@vbetsch vbetsch commented Aug 5, 2025

No description provided.

@vbetsch vbetsch requested a review from Copilot August 5, 2025 23:34
@vbetsch vbetsch self-assigned this Aug 5, 2025
@vbetsch vbetsch added api About endpoints and services architecture About folders, files, structure labels Aug 5, 2025
@notion-workspace
Copy link

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the authentication system by separating business errors from HTTP errors, implementing proper use cases for sign-in and registration, and improving API documentation structure. The changes introduce a cleaner separation of concerns and better error handling for authentication flows.

  • Separated business errors (with error codes) from generic HTTP errors
  • Introduced use cases for authentication operations with proper dependency injection
  • Created dedicated DTOs for authentication payloads and responses
  • Improved Swagger documentation with consistent tagging

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/modules/shared/errors/business-error-code.enum.ts Added USER_ALREADY_EXISTS error code
src/modules/shared/dto/output/errors/business.error.dto.ts New DTO for business errors with error codes
src/modules/shared/dto/output/errors/http.error.dto.ts Removed business error code from generic HTTP errors
src/modules/shared/dto/output/responses/abstract/http.response.dto.ts Updated to include BusinessErrorDto in response union
src/modules/shared/dto/output/data/sign-in.data.dto.ts New DTO for sign-in response data
src/modules/shared/dto/output/data/register.data.dto.ts New DTO for registration response data
src/modules/shared/dto/models/user.model.dto.ts New user model DTO
src/modules/shared/dto/input/payloads/register.payload.dto.ts New registration payload DTO
src/modules/api/usecases/auth/signin.usecase.ts New use case for sign-in logic
src/modules/api/usecases/auth/register.usecase.ts New use case for registration logic
src/modules/api/services/hash.service.ts New service for password hashing operations
src/modules/api/repositories/users.repository.ts New repository for user data operations
src/modules/api/errors/business/auth/user-already-exists.error.ts New business error for duplicate user registration
src/modules/api/adapters/user.adapter.ts New adapter for converting user entities to DTOs
src/lib/auth.ts Refactored to use SignInUseCase instead of direct database calls
src/app/api/auth/register/route.ts Completely refactored to use new architecture
Various route files Updated Swagger documentation tags for consistency
Comments suppressed due to low confidence (1)

src/modules/api/services/hash.service.ts:29

  • The parameter name 'hashedInput' is misleading. This parameter represents the plain text input to be compared against the hashed reference, not a hashed input. Consider renaming it to 'plainTextInput' or 'input' for clarity.
  public async compare(

@vbetsch vbetsch merged commit 5abe423 into develop Aug 5, 2025
4 checks passed
@vbetsch vbetsch deleted the api/refactor/132-register-login branch August 5, 2025 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api About endpoints and services architecture About folders, files, structure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants