feat: implement user profile endpoints (task 31)
- Add GET /api/users/:id for profile retrieval with stats - Add PATCH /api/users/:id for profile updates - Add GET /api/users/:id/reports to fetch user's reports - Add GET /api/users/:id/events to fetch user's events (registered & organized) - Add PATCH /api/users/:id/preferences for notification settings - Add POST /api/users/:id/calculate-impact for impact score calculation - Create userService with all business logic - Create userController with request handling - Create userRoutes and register in main server - Update frontend userService with new endpoints - Add comprehensive documentation in USER_PROFILE_ENDPOINTS.md - Add test script for manual endpoint testing Requirements satisfied: 6.3, 6.4, 6.5, 10.4
This commit is contained in:
21
server/src/routes/userRoutes.ts
Normal file
21
server/src/routes/userRoutes.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Router } from 'express';
|
||||
import { userController } from '../controllers/userController';
|
||||
import { requireAuth } from '../middleware/auth';
|
||||
|
||||
const router = Router();
|
||||
|
||||
// User profile endpoints
|
||||
router.get('/:id', userController.getUserProfile.bind(userController));
|
||||
router.patch('/:id', requireAuth, userController.updateUserProfile.bind(userController));
|
||||
|
||||
// User reports and events
|
||||
router.get('/:id/reports', userController.getUserReports.bind(userController));
|
||||
router.get('/:id/events', userController.getUserEvents.bind(userController));
|
||||
|
||||
// Notification preferences
|
||||
router.patch('/:id/preferences', requireAuth, userController.updateNotificationPreferences.bind(userController));
|
||||
|
||||
// Impact score calculation
|
||||
router.post('/:id/calculate-impact', userController.calculateImpactScore.bind(userController));
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user