Skip to content

Add Role Management API Routes #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2024
Merged

Add Role Management API Routes #16

merged 2 commits into from
Nov 10, 2024

Conversation

foyzulkarim
Copy link
Owner

@foyzulkarim foyzulkarim commented Nov 10, 2024

Overview

This PR implements the role management functionality by adding new API routes and the Role domain model. This is a part of a bigger feature which enables role-based access control (RBAC) in our application.

Changes

  • Added complete CRUD operations for Role management
  • Integrated role routes into the main Express router
  • Implemented Role schema with validation
  • Added request validation schemas for role operations

New Endpoints

  • GET /roles/search - Search roles with pagination and filtering
  • GET /roles/count - Get total count of roles
  • POST /roles - Create new role
  • GET /roles/:id - Get role by ID
  • PUT /roles/:id - Update role
  • DELETE /roles/:id - Delete role

Implementation Details

  • Role schema includes:
    • name (required, unique, lowercase)
    • displayName (required)
    • Base schema fields (created/updated timestamps)
  • Added request validation using Joi
  • Implemented error handling and logging
  • Protected routes with authorization middleware

Dependencies

  • Express.js
  • Mongoose
  • Joi for validation

Related Issues

foyzulkarim/commitstreams-client#22

Add role routes integration to the main router configuration, enabling role-related endpoints in the API.
- Add new fields to Role schema:
  - description (String, optional)
  - permissions (Array of Permission ObjectIds)
  - isSystem (Boolean) for system-level roles
- Update validation schemas for create and update operations
- Add ObjectId validation for permission references
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
65.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@foyzulkarim foyzulkarim changed the title Feature/rbac/role crud Add Role Management API Routes Nov 10, 2024
@foyzulkarim foyzulkarim marked this pull request as ready for review November 10, 2024 11:06
@foyzulkarim foyzulkarim merged commit 0e492f4 into main Nov 10, 2024
1 of 2 checks passed
@foyzulkarim foyzulkarim deleted the feature/rbac/role-crud branch November 10, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant