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

server routes 정리

parent 75cdec2c
...@@ -30,9 +30,9 @@ function MainRouter() { ...@@ -30,9 +30,9 @@ function MainRouter() {
<Route path="/quiz/by/:userId"> <Route path="/quiz/by/:userId">
<Quizzes /> <Quizzes />
</Route> </Route>
{/* <Route path="/quiz/problem/new/:quizId"> <Route path="/quiz/problem/new">
<NewProblem /> <NewProblem />
</Route> */} </Route>
<Route path="/quiz/problem/edit/:problemId"> <Route path="/quiz/problem/edit/:problemId">
<EditProblem /> <EditProblem />
</Route> </Route>
......
...@@ -5,7 +5,6 @@ import Col from "react-bootstrap/Col"; ...@@ -5,7 +5,6 @@ import Col from "react-bootstrap/Col";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
function NewProblem({ addProblem }) { function NewProblem({ addProblem }) {
const { quizId } = useParams();
const [answers, setAnswers] = useState([""]); const [answers, setAnswers] = useState([""]);
const [question, setQuestion] = useState(""); const [question, setQuestion] = useState("");
......
const create = async (params, credentials, quiz) => { const create = async (params, credentials, quiz) => {
try { try {
let response = await fetch('/api/quiz/by/' + params.userId, { let response = await fetch('/api/quiz/' + params.userId, {
method: 'POST', method: 'POST',
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
...@@ -18,7 +18,7 @@ const create = async (params, credentials, quiz) => { ...@@ -18,7 +18,7 @@ const create = async (params, credentials, quiz) => {
const read = async (params, credentials, signal) => { const read = async (params, credentials, signal) => {
try { try {
let response = await fetch('/api/quiz/' + params.quizId, { let response = await fetch('/api/quiz/by/' + params.quizId, {
method: 'GET', method: 'GET',
signal: signal, signal: signal,
headers: { headers: {
...@@ -35,7 +35,7 @@ const read = async (params, credentials, signal) => { ...@@ -35,7 +35,7 @@ const read = async (params, credentials, signal) => {
const readProblem = async (params, credentials, signal) => { const readProblem = async (params, credentials, signal) => {
try { try {
let response = await fetch('/api/quiz/problem/' + params.problemId, { let response = await fetch('/api/quiz/problem/by/' + params.problemId, {
method: 'GET', method: 'GET',
signal: signal, signal: signal,
headers: { headers: {
...@@ -52,7 +52,7 @@ const readProblem = async (params, credentials, signal) => { ...@@ -52,7 +52,7 @@ const readProblem = async (params, credentials, signal) => {
const updateProblem = async (params, credentials, problem) => { const updateProblem = async (params, credentials, problem) => {
try { try {
let response = await fetch('/api/quiz/problem/' + params.problemId, { let response = await fetch('/api/quiz/problem/by/' + params.problemId, {
method: 'PUT', method: 'PUT',
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
...@@ -69,7 +69,7 @@ const updateProblem = async (params, credentials, problem) => { ...@@ -69,7 +69,7 @@ const updateProblem = async (params, credentials, problem) => {
const removeProblem = async (params, credentials) => { const removeProblem = async (params, credentials) => {
try { try {
let response = await fetch('/api/quiz/problem/' + params.problemId, { let response = await fetch('/api/quiz/problem/by/' + params.problemId, {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
...@@ -85,7 +85,7 @@ const removeProblem = async (params, credentials) => { ...@@ -85,7 +85,7 @@ const removeProblem = async (params, credentials) => {
const listByUserId = async (params, credentials, signal) => { const listByUserId = async (params, credentials, signal) => {
try { try {
let response = await fetch('/api/quiz/by/' + params.userId, { let response = await fetch('/api/quiz/' + params.userId, {
method: 'GET', method: 'GET',
signal: signal, signal: signal,
headers: { headers: {
......
...@@ -5,14 +5,17 @@ import quizCtrl from './quiz.controller.js' ...@@ -5,14 +5,17 @@ import quizCtrl from './quiz.controller.js'
const router = express.Router() const router = express.Router()
router.route('/api/quiz/by/:userId') router.route('/api/quiz/:userId')
.post(authCtrl.requireSignin, authCtrl.hasAuthorization, userCtrl.isInstructor, quizCtrl.create) .post(authCtrl.requireSignin, authCtrl.hasAuthorization, userCtrl.isInstructor, quizCtrl.create)
.get(authCtrl.requireSignin, authCtrl.hasAuthorization, quizCtrl.listByUserId) .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) .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) .get(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.readProblem)
.put(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.updateProblem) .put(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.updateProblem)
.delete(authCtrl.requireSignin, quizCtrl.isProblemAuthor, quizCtrl.removeProblem) .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