This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refacto(users.ts): seperate file for user routes location (#2332)
* refacto(users.ts): seperate file for user routes location * chore(routes/users.ts): use distinct router for user api endpoint * chore: don't use base path for routers
- Loading branch information
1 parent
8bdd0bf
commit d61952c
Showing
2 changed files
with
92 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import express from 'express'; | ||
import * as usersController from '../controllers/usersController'; | ||
import routes from './routes'; | ||
import { publicGetRouteRateLimiter } from '@/middlewares/rateLimiter'; | ||
|
||
const router = express.Router(); | ||
const apiRouter = express.Router(); | ||
const publicApiRouter = express.Router(); | ||
|
||
// users | ||
router.post(routes.USER_CREATE_EMAIL, usersController.createEmailForUser); | ||
|
||
router.post(routes.USER_DELETE_EMAIL, usersController.deleteEmailForUser); | ||
router.post(routes.USER_UPGRADE_EMAIL, usersController.upgradeEmailForUser); | ||
|
||
router.post( | ||
routes.USER_CREATE_REDIRECTION, | ||
usersController.createRedirectionForUser | ||
); | ||
router.post( | ||
routes.USER_DELETE_REDIRECTION, | ||
usersController.deleteRedirectionForUser | ||
); | ||
router.post(routes.USER_UPDATE_PASSWORD, usersController.updatePasswordForUser); | ||
|
||
router.post( | ||
routes.USER_UPDATE_SECONDARY_EMAIL, | ||
usersController.manageSecondaryEmailForUser | ||
); | ||
router.post( | ||
routes.USER_UPDATE_PRIMARY_EMAIL, | ||
usersController.managePrimaryEmailForUser | ||
); | ||
router.post(routes.USER_UPDATE_END_DATE, usersController.updateEndDateForUser); | ||
|
||
apiRouter.post( | ||
routes.USER_DELETE_EMAIL_API, | ||
express.json({ type: '*/*' }), | ||
usersController.deleteEmailForUserApi | ||
); | ||
apiRouter.put( | ||
routes.USER_UPDATE_PRIMARY_EMAIL_API, | ||
express.json({ type: '*/*' }), | ||
usersController.managePrimaryEmailForUserApi | ||
); | ||
apiRouter.post( | ||
routes.USER_UPDATE_SECONDARY_EMAIL_API, | ||
express.json({ type: '*/*' }), | ||
usersController.manageSecondaryEmailForUserApi | ||
); | ||
apiRouter.post( | ||
routes.USER_UPDATE_PASSWORD_API, | ||
express.json({ type: '*/*' }), | ||
usersController.updatePasswordForUserApi | ||
); | ||
apiRouter.delete( | ||
routes.USER_DELETE_REDIRECTION_API, | ||
express.json({ type: '*/*' }), | ||
usersController.deleteRedirectionForUserApi | ||
); | ||
apiRouter.post( | ||
routes.USER_CREATE_REDIRECTION_API, | ||
express.json({ type: '*/*' }), | ||
usersController.createRedirectionForUserApi | ||
); | ||
apiRouter.post( | ||
routes.USER_UPGRADE_EMAIL_API, | ||
express.json({ type: '*/*' }), | ||
usersController.upgradeEmailForUserApi | ||
); | ||
apiRouter.post( | ||
routes.USER_CREATE_EMAIL_API, | ||
express.json({ type: '*/*' }), | ||
usersController.createEmailApi | ||
); | ||
|
||
publicApiRouter.get( | ||
routes.API_GET_PUBLIC_USER_INFO, | ||
publicGetRouteRateLimiter, | ||
usersController.getUserInfo | ||
); | ||
|
||
export { | ||
router as userRouter, | ||
apiRouter as userApiRouter, | ||
publicApiRouter as userPublicApiRouter, | ||
}; |