survey.route.ts 903 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")
Jiwon Yoon's avatar
Jiwon Yoon committed
13
  .get(authCtrl.requireLogin, authCtrl.authenticate, 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
27
  .post(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.addQuestion);

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

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

export default router;