survey.route.ts 1.08 KB
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);
Lee SeoYeon's avatar
Lee SeoYeon committed
7
router.route("/:surveyId").get(surveyCtrl.getSurveyById);
jang dong hyeok's avatar
jang dong hyeok committed
8

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

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

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

export default router;