auth.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import asyncHandler from "express-async-handler";
  2. import { Router } from "express";
  3. import * as validators from "../handlers/validators";
  4. import * as helpers from "../handlers/helpers";
  5. import * as auth from "../handlers/auth";
  6. const router = Router();
  7. router.post(
  8. "/login",
  9. validators.login,
  10. asyncHandler(helpers.verify),
  11. asyncHandler(auth.local),
  12. asyncHandler(auth.token)
  13. );
  14. router.post(
  15. "/signup",
  16. auth.signupAccess,
  17. validators.signup,
  18. asyncHandler(helpers.verify),
  19. asyncHandler(auth.signup)
  20. );
  21. router.post("/renew", asyncHandler(auth.jwt), asyncHandler(auth.token));
  22. router.post(
  23. "/change-password",
  24. asyncHandler(auth.jwt),
  25. validators.changePassword,
  26. asyncHandler(helpers.verify),
  27. asyncHandler(auth.changePassword)
  28. );
  29. router.post(
  30. "/change-email",
  31. asyncHandler(auth.jwt),
  32. validators.changePassword,
  33. asyncHandler(helpers.verify),
  34. asyncHandler(auth.changeEmailRequest)
  35. );
  36. router.post(
  37. "/apikey",
  38. asyncHandler(auth.jwt),
  39. asyncHandler(auth.generateApiKey)
  40. );
  41. router.post("/reset-password", asyncHandler(auth.resetPasswordRequest));
  42. export default router;