Skip to content

initial commit#284

Merged
yusuftomilola merged 4 commits intoDistinctCodes:mainfrom
shamoo53:user-module
Oct 1, 2025
Merged

initial commit#284
yusuftomilola merged 4 commits intoDistinctCodes:mainfrom
shamoo53:user-module

Conversation

@shamoo53
Copy link
Contributor

PR: Implement Standalone User Module

Overview

This PR introduces a standalone User module into the system, providing complete management of system users. The module is built using NestJS + TypeORM, includes input validation with class-validator, and ensures password security by hashing values before storage. It also provides RESTful APIs for creating, retrieving, updating, and deleting users, as well as mapping users to companies, departments, and branches.


Key Features

  • Database Entity:

    • New User entity with fields:

      • id (UUID, primary key)
      • fullName (string, required)
      • email (unique, required)
      • phoneNumber (optional, string)
      • passwordHash (string, hashed value of password)
      • role (enum/string)
      • Relations to company, department, and branch (future expansion)
  • DTOs & Validation:

    • CreateUserDto with validation for required fields (email format, password length, etc.)
    • UpdateUserDto supporting partial updates with validation rules
  • Service Layer:

    • createUser: Creates a new user with hashed password
    • findAllUsers: Returns a list of users
    • findOneUser: Retrieves a user by id
    • updateUser: Updates user details (supports role, name, etc.)
    • deleteUser: Removes a user by id
  • Controller Endpoints:

    • POST /users → Create new user
    • GET /users → Fetch all users
    • GET /users/:id → Fetch user by ID
    • PATCH /users/:id → Update user
    • DELETE /users/:id → Delete user
  • Password Security:

    • Passwords are hashed using bcrypt before being persisted
    • Plain-text passwords are never stored in the database

Tests

  • Added integration tests for all endpoints:

    • Create user with valid and invalid data
    • Fetch users (all and by ID)
    • Update user details
    • Delete user and verify removal
  • Validations tested (e.g., invalid email, short password)


Next Steps / Future Enhancements

  • Add relations for mapping users to companies, departments, and branches
  • Add authentication & authorization middleware (JWT-based login, role-based access control)
  • Improve test coverage with negative and edge cases

✅ This PR lays the foundation for user management across the system and ensures all user data is stored securely.

@vercel
Copy link

vercel bot commented Sep 30, 2025

@shamoo53 is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@yusuftomilola yusuftomilola merged commit 119e356 into DistinctCodes:main Oct 1, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants