survey.route.ts 916 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();

6
router.route("/").get(authCtrl.requireLogin, surveyCtrl.getSurveys);
jang dong hyeok's avatar
jang dong hyeok committed
7
8
9
10
router.route("/:surveyId")
.get(surveyCtrl.getSurveyById);


Jiwon Yoon's avatar
Jiwon Yoon committed
11

Jiwon Yoon's avatar
Jiwon Yoon committed
12
router.route("/create").post(authCtrl.requireLogin, surveyCtrl.createSurvey);
Jiwon Yoon's avatar
Jiwon Yoon committed
13
router
14
15
  .route("/:surveyId")
  .get(surveyCtrl.getSurveyById);
Jiwon Yoon's avatar
Jiwon Yoon committed
16
router
jang dong hyeok's avatar
.    
jang dong hyeok committed
17
  .route("/:surveyId/edit")
Jiwon Yoon's avatar
Jiwon Yoon committed
18
19
  .get(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.getSurveyById)
  .put(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.updateSurvey);
20
router
jang dong hyeok's avatar
jang dong hyeok committed
21
  .route("/:surveyId/delete")
22
23
24
25
26
27
  .delete(
    authCtrl.requireLogin,
    authCtrl.authenticate,
    surveyCtrl.deleteSurvey
  );

Jiwon Yoon's avatar
Jiwon Yoon committed
28
29
30
31
router
  .route("/:surveyId/questions")
  .post(authCtrl.requireLogin, questionCtrl.createQuestion);

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

export default router;