Add user and event lookup endpoints#44
Merged
lnqminh3003 merged 2 commits intobackendfrom Jan 26, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements three new GET endpoints for retrieving user and event information by ID.
Changes
New 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
Files Modified
src/controllers/user_controller.ts- AddedgetUserByIdandgetUserEventsfunctionssrc/routes/user_route.ts- Added routes with proper ordering to avoid conflictssrc/controllers/event_controller.ts- AddedgetEventByIdfunctionsrc/routes/event_routes.ts- Added route for event by IDImplementation Details
{ success: true/false, ... }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