Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 17:51:59 +08:00
commit 38e80921c8
89 changed files with 20480 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/**
* User Routes - GET endpoint example
*
* @route GET /api/users/:id
* @access Private
*/
import { Router, Request, Response, NextFunction } from 'express';
import { authMiddleware } from '../middleware/auth';
const router = Router();
/**
* GET /api/users/:id
* @description Get user by ID
* @access Private
*/
router.get(
'/api/users/:id',
authMiddleware,
async (req: Request, res: Response, next: NextFunction) => {
try {
const { id } = req.params;
// TODO: Fetch user from database
const user = await getUserById(id);
if (!user) {
return res.status(404).json({
success: false,
error: 'User not found',
});
}
res.status(200).json({
success: true,
data: user,
});
} catch (error) {
next(error);
}
}
);
export default router;
// Mock function (replace with actual database query)
async function getUserById(id: string) {
return {
id,
name: 'John Doe',
email: 'john@example.com',
};
}