-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.js
34 lines (30 loc) · 1.06 KB
/
router.js
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
import { registerUser, loginUser } from "./controllers/auth.js";
import {
addProblem,
editProblem,
deleteProblem,
addTestcase,
editTestcase,
} from "./controllers/admin.js";
import {
getAllProblems,
createSubmission,
checkResult,
} from "./controllers/users.js";
import { Router } from "express";
import { isAuth, isAdmin } from "./middlewares.js";
const router = Router();
//AUTH
router.post("/login", loginUser);
router.post("/register", registerUser);
//ADMIN
router.post("/admin/add-problem", isAuth, isAdmin, addProblem);
router.put("/admin/edit-problem/:problemId", isAuth, isAdmin, editProblem);
router.delete("/admin/delete-problem/:problemId", isAuth, isAdmin, deleteProblem);
router.post("/admin/add-testcase/:problemId", isAuth, isAdmin, addTestcase);
router.put("/admin/edit-testcase/:problemId/:testcaseId", isAuth, isAdmin, editTestcase);
//USER
router.get("/user/all-problems", isAuth, getAllProblems);
router.post("/user/submit-answer", isAuth, createSubmission);
router.get("/user/result/:submissionId", isAuth, checkResult);
export default router;