Skip to content

Comments

Add user and event lookup endpoints#44

Merged
lnqminh3003 merged 2 commits intobackendfrom
user-event-lookup-endpoints
Jan 26, 2026
Merged

Add user and event lookup endpoints#44
lnqminh3003 merged 2 commits intobackendfrom
user-event-lookup-endpoints

Conversation

@rxmox
Copy link
Collaborator

@rxmox rxmox commented Jan 26, 2026

Summary

Implements three new GET endpoints for retrieving user and event information by ID.

Changes

New Endpoints

  1. GET /api/users/:userId - Get user by ID

    • Returns user information excluding passwordHash for security
    • Returns 404 if user not found
  2. GET /api/events/:eventId - Get event by ID

    • Returns event details with populated participant information
    • Returns 404 if event not found
  3. GET /api/users/:userId/events - Get all events a user has joined

    • Returns array of events from user's event history
    • Returns empty array if user has no event history

Files Modified

  • src/controllers/user_controller.ts - Added getUserById and getUserEvents functions
  • src/routes/user_route.ts - Added routes with proper ordering to avoid conflicts
  • src/controllers/event_controller.ts - Added getEventById function
  • src/routes/event_routes.ts - Added route for event by ID

Implementation Details

  • All endpoints follow existing code patterns and error handling
  • Consistent response format: { success: true/false, ... }
  • Proper validation and 404 handling for missing resources
  • Security: passwordHash excluded from user queries
  • Route ordering configured correctly to prevent conflicts

Test Plan

All endpoints have been tested and verified:

Test Results

✅ GET /api/users/:userId - Returns user with all fields (passwordHash excluded)
✅ GET /api/events/:eventId - Returns event with populated participant details
✅ GET /api/users/:userId/events - Returns array of user's events
✅ 404 handling - Returns appropriate errors for non-existent resources
✅ Empty arrays - Correctly handles users with no event history
✅ TypeScript compilation - No build errors

Manual Testing Commands

# Test get user by ID
curl http://localhost:4000/api/users/{userId}

# Test get event by ID
curl http://localhost:4000/api/events/{eventId}

# Test get user's events
curl http://localhost:4000/api/users/{userId}/events

Implement three new GET endpoints:
- GET /api/users/:userId - Get user by ID
- GET /api/events/:eventId - Get event by ID
- GET /api/users/:userId/events - Get all events a user has joined

All endpoints follow existing patterns with proper error handling, validation, and response formats.
@rxmox rxmox requested review from keeryn04 and lnqminh3003 January 26, 2026 03:18
@lnqminh3003 lnqminh3003 merged commit f18fdbc into backend Jan 26, 2026
1 check passed
@rxmox rxmox deleted the user-event-lookup-endpoints branch February 16, 2026 03:12
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