cleaning up api and testing getting conversations and such

This commit is contained in:
talksik
2022-06-11 10:18:27 -05:00
parent e39316eeff
commit c898402b31
5 changed files with 59 additions and 4 deletions
+16
View File
@@ -23,6 +23,9 @@ export default function getUserRoutes() {
router.get('/login', login);
// get user public information by id
router.get('/:userId', authCheck, getPublicUser);
router.get('/authcheck', authCheck, handleAuthCheck);
return router;
@@ -45,6 +48,19 @@ async function getUserDetails(req: Request, res: Response, next: NextFunction) {
next(Error('No user found'));
}
async function getPublicUser(req: Request, res: Response, next: NextFunction) {
const { userId } = req.params;
const user = await UserService.getUserById(userId as string);
if (user) {
return res.status(200).json(new UserDetailsResponse(user));
}
res.status(404);
next(Error('No user found'));
}
/** Create user if doesn't exist
* Returns jwt token for client and user details
*/