links.ts 746 B

123456789101112131415161718192021222324252627282930313233
  1. import { Router } from "express";
  2. import asyncHandler from "express-async-handler";
  3. import cors from "cors";
  4. import * as auth from "../handlers/auth";
  5. import * as validators from "../handlers/validators";
  6. import * as sanitizers from "../handlers/sanitizers";
  7. import * as helpers from "../handlers/helpers";
  8. import { getLinks, createLink } from "../handlers/links";
  9. const router = Router();
  10. router.get(
  11. "/",
  12. asyncHandler(auth.apikey),
  13. asyncHandler(auth.jwt),
  14. helpers.query,
  15. getLinks
  16. );
  17. router.post(
  18. "/",
  19. cors(),
  20. asyncHandler(auth.apikey),
  21. asyncHandler(auth.jwtLoose),
  22. asyncHandler(auth.recaptcha),
  23. sanitizers.createLink,
  24. validators.createLink,
  25. asyncHandler(validators.verify),
  26. createLink
  27. );
  28. export default router;