April 2020
Intermediate to advanced
716 pages
18h 55m
English
In order to start the implementation of the create course API in the backend, we will add a POST route that verifies that the current user is an educator, and then creates a new course with the course data passed in the request body. The route is defined as follows:
mern-classroom/server/routes/course.routes.js:
router.route('/api/courses/by/:userId') .post(authCtrl.requireSignin, authCtrl.hasAuthorization, userCtrl.isEducator, courseCtrl.create)
The course.routes.js file will be very similar to the user.routes file, and to load these new routes in the Express app, we need to mount the course routes in express.js, in the same way that we did for the auth and user routes, as shown in the following code:
mern-classroom/server/express.js ...
Read now
Unlock full access