survey.route.ts 771 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,
    questionCtrl.createQuestion
  );
Jiwon Yoon's avatar
Jiwon Yoon committed
28

Jiwon Yoon's avatar
Jiwon Yoon committed
29
router.param("surveyId", surveyCtrl.userBySurveyId);
Jiwon Yoon's avatar
Jiwon Yoon committed
30
31

export default router;