auth.ts 949 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. "/apikey",
  31. asyncHandler(auth.jwt),
  32. asyncHandler(auth.generateApiKey)
  33. );
  34. router.post("/reset-password", asyncHandler(auth.resetPasswordRequest));
  35. export default router;