Commit e7c36007 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

server routes 정리

parent 75cdec2c
......@@ -30,9 +30,9 @@ function MainRouter() {
<Route path="/quiz/by/:userId">
<Quizzes />
</Route>
{/* <Route path="/quiz/problem/new/:quizId">
<Route path="/quiz/problem/new">
<NewProblem />
</Route> */}
</Route>
<Route path="/quiz/problem/edit/:problemId">
<EditProblem />
</Route>
......
......@@ -5,7 +5,6 @@ import Col from "react-bootstrap/Col";
import { useParams } from "react-router-dom";
function NewProblem({ addProblem }) {
const { quizId } = useParams();
const [answers, setAnswers] = useState([""]);
const [question, setQuestion] = useState("");
......
const create = async (params, credentials, quiz) => {
try {
let response = await fetch('/api/quiz/by/' + params.userId, {
let response = await fetch('/api/quiz/' + params.userId, {
method: 'POST',
headers: {
'Accept': 'application/json',
......@@ -18,7 +18,7 @@ const create = async (params, credentials, quiz) => {
const read = async (params, credentials, signal) => {
try {
let response = await fetch('/api/quiz/' + params.quizId, {
let response = await fetch('/api/quiz/by/' + params.quizId, {
method: 'GET',
signal: signal,
headers: {
......@@ -35,7 +35,7 @@ const read = async (params, credentials, signal) => {
const readProblem = async (params, credentials, signal) => {
try {
let response = await fetch('/api/quiz/problem/' + params.problemId, {
let response = await fetch('/api/quiz/problem/by/' + params.problemId, {
method: 'GET',
signal: signal,
headers: {
......@@ -52,7 +52,7 @@ const readProblem = async (params, credentials, signal) => {
const updateProblem = async (params, credentials, problem) => {
try {
let response = await fetch('/api/quiz/problem/' + params.problemId, {
let response = await fetch('/api/quiz/problem/by/' + params.problemId, {
method: 'PUT',
headers: {
'Accept': 'application/json',
......@@ -69,7 +69,7 @@ const updateProblem = async (params, credentials, problem) => {
const removeProblem = async (params, credentials) => {
try {
let response = await fetch('/api/quiz/problem/' + params.problemId, {
let response = await fetch('/api/quiz/problem/by/' + params.problemId, {
method: 'DELETE',
headers: {
'Accept': 'application/json',
......@@ -85,7 +85,7 @@ const removeProblem = async (params, credentials) => {
const listByUserId = async (params, credentials, signal) => {
try {
let response = await fetch('/api/quiz/by/' + params.userId, {
let response = await fetch('/api/quiz/' + params.userId, {
method: 'GET',
signal: signal,
headers: {
......
......@@ -5,14 +5,17 @@ import quizCtrl from './quiz.controller.js'
const router = express.Router()
router.route('/api/quiz/by/:userId')
router.route('/api/quiz/:userId')
.post(authCtrl.requireSignin, authCtrl.hasAuthorization, userCtrl.isInstructor, quizCtrl.create)
.get(authCtrl.requireSignin, authCtrl.hasAuthorization, quizCtrl.listByUserId)
router.route('/api/quiz/:quizId')
router.route('/api/quiz/by/:quizId')
.get(authCtrl.requireSignin, quizCtrl.isAuthor, quizCtrl.read)
router.route('/api/quiz/problem/:problemId')
router.route('/api/quiz/problem/:userId')
.post(authCtrl.requireSignin, userCtrl.isInstructor)
router.route('/api/quiz/problem/by/:problemId')
.get(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.readProblem)
.put(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.updateProblem)
.delete(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.removeProblem)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment