|
1 | | -import express, { NextFunction, Request, Response } from 'express'; |
| 1 | +import express from 'express'; |
2 | 2 | import auth from '../../middlewares/auth'; |
3 | 3 | import validateRequest from '../../middlewares/validateRequest'; |
4 | 4 | import { UserController } from './user.controller'; |
5 | 5 | import { UserValidation } from './user.validation'; |
6 | 6 | import fileUploadHandler from '../../middlewares/fileUploadHandler'; |
7 | | -import { USER_ROLES } from './user.constant'; |
8 | 7 | const router = express.Router(); |
9 | 8 |
|
10 | | -router |
11 | | - .route('/profile') |
12 | | - .get(auth(USER_ROLES.ADMIN, USER_ROLES.USER), UserController.getUserProfile) |
13 | | - .patch( |
14 | | - auth(USER_ROLES.SUPER_ADMIN, USER_ROLES.ADMIN, USER_ROLES.USER), |
15 | | - fileUploadHandler(), |
16 | | - (req: Request, res: Response, next: NextFunction) => { |
17 | | - if (req.body.data) { |
18 | | - req.body = UserValidation.updateUserZodSchema.parse( |
19 | | - JSON.parse(req.body.data) |
20 | | - ); |
21 | | - } |
22 | | - return UserController.updateProfile(req, res, next); |
23 | | - } |
24 | | - ); |
| 9 | +// create user |
| 10 | +router.post( |
| 11 | + '/create-user', |
| 12 | + validateRequest(UserValidation.createUserZodSchema), |
| 13 | + UserController.createUser |
| 14 | +); |
25 | 15 |
|
26 | | -router |
27 | | - .route('/') |
28 | | - .post( |
29 | | - validateRequest(UserValidation.createUserZodSchema), |
30 | | - UserController.createUser |
31 | | - ); |
| 16 | +// update profile |
| 17 | +router.patch( |
| 18 | + '/profile', |
| 19 | + auth(), |
| 20 | + fileUploadHandler(), |
| 21 | + validateRequest(UserValidation.updateUserZodSchema), |
| 22 | + UserController.updateProfile |
| 23 | +); |
| 24 | + |
| 25 | +// get profile |
| 26 | +router.get('/profile', auth(), UserController.getUserProfile); |
32 | 27 |
|
33 | 28 | export const UserRoutes = router; |
0 commit comments