-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson 05 Task Manager API Part 1 of 2
Here, and in several lessons to follow, the students are just instructed to duplicate the work of the instructor from the video. Now, this is admittedly tedious, but it does seem to give the students finger memory of the key concepts, and the approach gives the students a good chance of success in a complicated process. The students can just c/p from the final directory, but we do encourage them to do their own work instead of c/p.
A note to reviewers: Make sure the student submission includes an appropriate .gitignore and does not include the .env file or /node_express directory. The .env file is especially important, as it includes the student’s Atlas Mongo password. Pay special attention to quizAnswers.txt
, which has students’ responses to some open-ended questions. Also, there is an optional warm up assignment on Array methods, in 03-task-manager/optionalArrayMethodsReviewExtraAssignment.js. Reviewers should evaluate this as part of the assignment PR.
This is where we get into the real meat of the course, with access to the MongoDB database. Mentors should also create MongoDB accounts, and I recommend that you run the task manager application and verify that it is working correctly. You can use the final application as present in the 03-task-manager/final directory, but you have to create a .env file with a MONGO_URI corresponding to your account and DB password. The instructor provides a front end for the application that students can use, but we want to emphasize the use of Postman to exercise the REST operations for CRUD. All database operations use the async/await pattern, and the instructor describes the use of an async wrapper to catch errors. These are good topics to review in your session. (Later on we will configure Express to do the wrapping of async operations automatically, so the async wrapper is just temporary to explain what is going on.) You can explain some of the history: It used to be necessary to wrapper async/await functions explicitly, as this code does. Then the express-async-errors npm package was created to do the wrappering automatically. And now, with current versions of Express, the express-async-errors package is already built in — you do not have to install or require it separately.
In this lesson, you may also want to stress the organization of the application into route, model, and controller files, plus middleware.
The Mongoose package is used for Mongo access to facilitate the creation of an apparent schema. Of course, this schema is just imposed within the application, as MongoDB itself is schemaless.