Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.ts « __v1 « server - github.com/thedevs-network/kutt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 90f76293710ff5ccabb9e451b87282e9736ec53a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import asyncHandler from "express-async-handler";
import { Router } from "express";
import cors from "cors";

import {
  validateUrl,
  ipCooldownCheck
} from "./controllers/validateBodyController";
import * as auth from "../handlers/auth";
import * as link from "./controllers/linkController";
import env from "../env";

const router = Router();

/* URL shortener */
router.post(
  "/url/submit",
  cors(),
  asyncHandler(auth.apikey),
  asyncHandler(env.DISALLOW_ANONYMOUS_LINKS ? auth.jwt : auth.jwtLoose),
  asyncHandler(auth.recaptcha),
  asyncHandler(validateUrl),
  asyncHandler(ipCooldownCheck),
  asyncHandler(link.shortener)
);
router.post(
  "/url/deleteurl",
  asyncHandler(auth.apikey),
  asyncHandler(auth.jwt),
  asyncHandler(link.deleteUserLink)
);
router.get(
  "/url/geturls",
  asyncHandler(auth.apikey),
  asyncHandler(auth.jwt),
  asyncHandler(link.getUserLinks)
);
router.post(
  "/url/customdomain",
  asyncHandler(auth.jwt),
  asyncHandler(link.setCustomDomain)
);
router.delete(
  "/url/customdomain",
  asyncHandler(auth.jwt),
  asyncHandler(link.deleteCustomDomain)
);
router.get(
  "/url/stats",
  asyncHandler(auth.apikey),
  asyncHandler(auth.jwt),
  asyncHandler(link.getLinkStats)
);
router.post("/url/requesturl", asyncHandler(link.goToLink));
router.post("/url/report", asyncHandler(link.reportLink));
router.post(
  "/url/admin/ban",
  asyncHandler(auth.apikey),
  asyncHandler(auth.jwt),
  asyncHandler(auth.admin),
  asyncHandler(link.ban)
);

export default router;