-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(*): change the term user to learner
- also move database logic from schemas to services
- Loading branch information
Showing
13 changed files
with
113 additions
and
112 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
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
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { Router } from "express"; | ||
import authRouter from "./auth.route"; | ||
import subjectRouter from "./subject.route"; | ||
import userRouter from "./user.route"; | ||
import learnerRouter from "./learner.route"; | ||
import tutorRouter from "./tutor.route"; | ||
|
||
const v1Router = Router(); | ||
|
||
v1Router.use("/auth", authRouter); | ||
v1Router.use("/subjects", subjectRouter); | ||
v1Router.use("/users", userRouter); | ||
v1Router.use("/learners", learnerRouter); | ||
v1Router.use("/tutors", tutorRouter); | ||
|
||
export default v1Router; |
28 changes: 14 additions & 14 deletions
28
src/routes/v1/user.route.ts → src/routes/v1/learner.route.ts
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 |
---|---|---|
@@ -1,39 +1,39 @@ | ||
import * as userController from "@controllers/user.controller"; | ||
import * as learnerController from "@controllers/learner.controller"; | ||
import { | ||
firebaseAuthMiddleware, | ||
verifyUser, | ||
verifyLearner, | ||
} from "@middleware/auth.middleware"; | ||
import { | ||
validateProfilePictureUpload, | ||
validator, | ||
} from "@middleware/validation.middleware"; | ||
import { changePasswordSchema } from "@schemas/auth.schema"; | ||
import { updateProfileSchema } from "@schemas/user.schema"; | ||
import { updateProfileSchema } from "@schemas/learner.schema"; | ||
import { Router } from "express"; | ||
|
||
// /api/v1/users | ||
const userRouter = Router(); | ||
userRouter.use(firebaseAuthMiddleware); | ||
userRouter.use(verifyUser); | ||
// /api/v1/learners | ||
const learnerRouter = Router(); | ||
learnerRouter.use(firebaseAuthMiddleware); | ||
learnerRouter.use(verifyLearner); | ||
|
||
userRouter.patch( | ||
learnerRouter.patch( | ||
"/profile", | ||
validator(updateProfileSchema), | ||
userController.updateProfile, | ||
learnerController.updateProfile, | ||
); | ||
|
||
userRouter.put( | ||
learnerRouter.put( | ||
"/profile/picture", | ||
validateProfilePictureUpload, | ||
userController.updateProfilePicture, | ||
learnerController.updateProfilePicture, | ||
); | ||
|
||
// TODO: harus validasi dulu password lamanya. Di firebase-admin ga ada kayak compare password | ||
// jadi harus di handle di client atau generate password reset link yang dikirim di email | ||
userRouter.put( | ||
learnerRouter.put( | ||
"/password", | ||
validator(changePasswordSchema), | ||
userController.changePassword, | ||
learnerController.changePassword, | ||
); | ||
|
||
export default userRouter; | ||
export default learnerRouter; |
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
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
Oops, something went wrong.