survey.route.ts 937 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
import express from "express";
Jiwon Yoon's avatar
Jiwon Yoon committed
2
import { authCtrl, surveyCtrl, questionCtrl } from "../controllers";
Jiwon Yoon's avatar
Jiwon Yoon committed
3
4
5

const router = express.Router();

Yoon, Daeki's avatar
Yoon, Daeki committed
6
7
8
9
router
  .route("/")
  .get(authCtrl.requireLogin, surveyCtrl.getSurveys)
  .post(authCtrl.requireLogin, surveyCtrl.createSurvey);
10

Jiwon Yoon's avatar
Jiwon Yoon committed
11
router
Yoon, Daeki's avatar
Yoon, Daeki committed
12
  .route("/:surveyId")
13
  .get(surveyCtrl.getSurveyById)
Yoon, Daeki's avatar
Yoon, Daeki committed
14
  .put(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.updateSurvey)
15
16
17
18
19
20
  .delete(
    authCtrl.requireLogin,
    authCtrl.authenticate,
    surveyCtrl.deleteSurvey
  );

Jiwon Yoon's avatar
Jiwon Yoon committed
21
22
router
  .route("/:surveyId/questions")
Yoon, Daeki's avatar
Yoon, Daeki committed
23
24
25
26
  .post(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.addQuestion);

router
  .route("/:surveyId/questions/:questionId")
Yoon, Daeki's avatar
Yoon, Daeki committed
27
  .put(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.updateQuestion)
Yoon, Daeki's avatar
Yoon, Daeki committed
28
  .delete(
Yoon, Daeki's avatar
Yoon, Daeki committed
29
30
    authCtrl.requireLogin,
    authCtrl.authenticate,
Yoon, Daeki's avatar
Yoon, Daeki committed
31
    surveyCtrl.deleteQuestion
Yoon, Daeki's avatar
Yoon, Daeki committed
32
  );
Jiwon Yoon's avatar
Jiwon Yoon committed
33

Jiwon Yoon's avatar
Jiwon Yoon committed
34
router.param("surveyId", surveyCtrl.userBySurveyId);
Jiwon Yoon's avatar
Jiwon Yoon committed
35
36

export default router;