|
2 | 2 | // jshint node: true |
3 | 3 | "use strict"; |
4 | 4 |
|
5 | | -var express = require("express"); |
6 | | -var TutorialRouter = express.Router(); |
| 5 | +const express = require("express"); |
| 6 | +const TutorialRouter = express.Router(); |
7 | 7 |
|
8 | 8 | const { userAuthorization } = require("../../helper/userAuthorization"); |
9 | 9 | const { upload } = require("../../helper/imageUpload"); |
10 | 10 |
|
11 | | -TutorialRouter.route("/").post( |
12 | | - userAuthorization, |
13 | | - upload.any(), |
14 | | - require("./postTutorial").postTutorial |
15 | | -); |
| 11 | +// Tutorial CRUD |
| 12 | +const { postTutorial } = require("./postTutorial"); |
| 13 | +const { putTutorial } = require("./putTutorial"); |
| 14 | +const { deleteTutorial } = require("./deleteTutorial"); |
| 15 | +const { getTutorial } = require("./getTutorial"); |
| 16 | +const { getTutorials } = require("./getTutorials"); |
| 17 | +const { getAllTutorials } = require("./getAllTutorials"); |
| 18 | +const { getUserTutorials } = require("./getUserTutorials"); |
| 19 | + |
| 20 | +// Tutorial Progress |
| 21 | +const { startTutorial } = require("./tutorialProgress/startTutorial"); |
| 22 | +const { markStepSeen } = require("./tutorialProgress/markStepSeen"); |
| 23 | +const { answerQuestion } = require("./tutorialProgress/answerQuestion"); |
| 24 | +const { getProgress } = require("./tutorialProgress/getProgress"); |
| 25 | +const { deleteProgress } = require("./tutorialProgress/deleteProgress"); |
| 26 | +const { getAllProgress } = require("./tutorialProgress/getAllProgress"); |
| 27 | + |
| 28 | +/* ---------- LIST ROUTES ---------- */ |
| 29 | + |
| 30 | +TutorialRouter.get("/", getTutorials); |
| 31 | +TutorialRouter.get("/getAllTutorials", userAuthorization, getAllTutorials); |
| 32 | +TutorialRouter.get("/getUserTutorials", userAuthorization, getUserTutorials); |
| 33 | + |
| 34 | +/* ---------- PROGRESS ROUTES (FIRST!) ---------- */ |
| 35 | + |
| 36 | +// 🔥 alle Progresse des Users |
| 37 | +TutorialRouter.get("/progress", userAuthorization, getAllProgress); |
16 | 38 |
|
17 | | -TutorialRouter.route("/:tutorialId").put( |
| 39 | +// 🔥 Progress eines Tutorials |
| 40 | +TutorialRouter.get("/:tutorialId/progress", userAuthorization, getProgress); |
| 41 | + |
| 42 | +TutorialRouter.post( |
| 43 | + "/:tutorialId/steps/:stepId/seen", |
18 | 44 | userAuthorization, |
19 | | - upload.any(), |
20 | | - require("./putTutorial").putTutorial |
| 45 | + markStepSeen |
21 | 46 | ); |
22 | 47 |
|
23 | | -TutorialRouter.route("/:tutorialId").delete( |
| 48 | +TutorialRouter.post( |
| 49 | + "/:tutorialId/steps/:stepId/questions/answer", |
24 | 50 | userAuthorization, |
25 | | - require("./deleteTutorial").deleteTutorial |
| 51 | + answerQuestion |
26 | 52 | ); |
27 | 53 |
|
28 | | -TutorialRouter.route("/").get(require("./getTutorials").getTutorials); |
| 54 | +TutorialRouter.post("/:tutorialId/start", userAuthorization, startTutorial); |
29 | 55 |
|
30 | | -TutorialRouter.route("/getAllTutorials").get( |
| 56 | +TutorialRouter.delete( |
| 57 | + "/:tutorialId/progress", |
31 | 58 | userAuthorization, |
32 | | - require("./getAllTutorials").getAllTutorials |
| 59 | + deleteProgress |
33 | 60 | ); |
34 | 61 |
|
35 | | -TutorialRouter.route("/getUserTutorials").get( |
| 62 | +/* ---------- CRUD ROUTES ---------- */ |
| 63 | + |
| 64 | +TutorialRouter.post("/", userAuthorization, upload.any(), postTutorial); |
| 65 | + |
| 66 | +TutorialRouter.put( |
| 67 | + "/:tutorialId", |
36 | 68 | userAuthorization, |
37 | | - require("./getUserTutorials").getUserTutorials |
| 69 | + upload.any(), |
| 70 | + putTutorial |
38 | 71 | ); |
39 | 72 |
|
40 | | -TutorialRouter.route("/:tutorialId").get(require("./getTutorial").getTutorial); |
| 73 | +TutorialRouter.delete("/:tutorialId", userAuthorization, deleteTutorial); |
| 74 | + |
| 75 | +/* ---------- LAST: SINGLE TUTORIAL ---------- */ |
| 76 | + |
| 77 | +TutorialRouter.get("/:tutorialId", getTutorial); |
41 | 78 |
|
42 | 79 | module.exports = TutorialRouter; |
0 commit comments