Skip to content

CRU Learning Hub #32

@Stacvirus

Description

@Stacvirus

Epic: CRU Learning Hub - Backend
Priority: High

Description

Implement the Learning entity, representing course modules in the CRU Learning Hub. This includes creating the database table, establishing relationships (e.g., owner via userId, technologies), and basic CRUD APIs for authenticated users to manage their learnings.

Acceptance Criteria

  1. Database Setup:
  • Create learnings table with fields: id (UUID), name (string), description (string), userId (foreign key to users.id), content_url (string, optional), technologies (array of Tech IDs), duration (integer, minutes), level (enum: 'Beginner', 'Intermediate', 'Advanced') in capital letters, createdAt (timestamp), updatedAt (timestamp).

  • Add indexes on userId, name and level.

  • CRUD APIs (Authenticated via JWT):

  • POST /api/v1/learnings: Create new learning (validate inputs, set owner to current user).

  • GET /api/v1/learnings: List learnings (filter by level or userId).

  • GET /api/v1/learnings/:id: Retrieve single learning (include technologies).

  • PATCH /api/v1/learnings/:id: Update learning (only by owner).

  • DELETE /api/v1/learnings/:id: Delete learning (only by owner).

  1. Response Examples:
json{  
  "success": true,  
  "learning": {  
    "id": "<uuid>",  
    "name": "React Basics",  
    "description": "Intro to React",  
    "userId": "<user_uuid>",  
    "content_url": "https://example.com/video",  
    "technologies": ["tech1_id", "tech2_id"],  
    "duration": 120,  
    "level": "Beginner",  
    "created_at": "<timestamp>",  
    "updated_at": "<timestamp>"  
  }  
}
  1. Security & Logging:
  • Enforce ownership checks (only owner can CRUD).
  • Log actions with userId and timestamp (no sensitive data, aligned with Ticket 29).
  1. Testing (Jest):
  • Unit Tests:

  • Validate create/update inputs.

  • Ownership enforcement.

  • Integration Tests:

  • Database insertion/retrieval with relations.

  • Error handling (e.g., invalid level).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions