auth.ts 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. validators.signup,
  17. asyncHandler(helpers.verify),
  18. asyncHandler(auth.signup)
  19. );
  20. router.post("/renew", asyncHandler(auth.jwt), asyncHandler(auth.token));
  21. router.post(
  22. "/change-password",
  23. asyncHandler(auth.jwt),
  24. validators.changePassword,
  25. asyncHandler(helpers.verify),
  26. asyncHandler(auth.changePassword)
  27. );
  28. router.post(
  29. "/apikey",
  30. asyncHandler(auth.jwt),
  31. asyncHandler(auth.generateApiKey)
  32. );
  33. router.post("/reset-password", asyncHandler(auth.resetPasswordRequest));
  34. export default router;