quiz.routes.js 1.2 KB
Newer Older
Yoon, Daeki's avatar
quiz    
Yoon, Daeki committed
1
2
3
4
5
6
7
import express from 'express'
import authCtrl from '../auth/auth.controller.js'
import userCtrl from '../user/user.controller.js'
import quizCtrl from './quiz.controller.js'

const router = express.Router()

Yoon, Daeki's avatar
Yoon, Daeki committed
8
router.route('/api/quiz/:userId')
Yoon, Daeki's avatar
Yoon, Daeki committed
9
10
  .post(authCtrl.requireSignin, authCtrl.hasAuthorization, userCtrl.isInstructor, quizCtrl.create) // 퀴즈 생성
  .get(authCtrl.requireSignin, authCtrl.hasAuthorization, quizCtrl.listByUserId) // 모든 퀴즈 반환
Yoon, Daeki's avatar
Yoon, Daeki committed
11

Yoon, Daeki's avatar
Yoon, Daeki committed
12
router.route('/api/quiz/by/:quizId')
Yoon, Daeki's avatar
Yoon, Daeki committed
13
  .get(authCtrl.requireSignin, quizCtrl.isAuthor, quizCtrl.read) // 퀴즈 하나 반환
Yoon, Daeki's avatar
quiz    
Yoon, Daeki committed
14

Yoon, Daeki's avatar
Yoon, Daeki committed
15
router.route('/api/quiz/problem/:userId')
Yoon, Daeki's avatar
Yoon, Daeki committed
16
  .post(authCtrl.requireSignin, userCtrl.isInstructor, quizCtrl.createProblem) // 문제 생성
Yoon, Daeki's avatar
Yoon, Daeki committed
17
18

router.route('/api/quiz/problem/by/:problemId')
Yoon, Daeki's avatar
Yoon, Daeki committed
19
20
21
  .get(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.readProblem) // 문제 반환
  .put(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.updateProblem) // 문제 수정
  .delete(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.removeProblem) // 문제 삭제
Yoon, Daeki's avatar
quiz    
Yoon, Daeki committed
22
23

router.param('userId', userCtrl.userById)
Yoon, Daeki's avatar
Yoon, Daeki committed
24
router.param('quizId', quizCtrl.quizById)
Yoon, Daeki's avatar
Yoon, Daeki committed
25
26
router.param('problemId', quizCtrl.problemById)

Yoon, Daeki's avatar
quiz    
Yoon, Daeki committed
27
export default router