|
| 1 | +# Authentication and Testing Sprint Challenge |
| 2 | + |
| 3 | +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** |
| 4 | + |
| 5 | +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **Authentication and Testing**. During this sprint, you studied **authentication, JSON web tokens, unit testing, and backend testing**. In your challenge this week, you will demonstrate your mastery of these skills by creating **a dad jokes app**. |
| 6 | + |
| 7 | +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers on Monday following the challenge submission. For more information on the review process [click here.](https://www.notion.so/bloomtech/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a) |
| 8 | + |
| 9 | +You are not allowed to collaborate during the sprint challenge. |
| 10 | + |
| 11 | +## Project Setup |
| 12 | + |
| 13 | +- [ ] Run `npm install` to install your dependencies. |
| 14 | +- [ ] Build your database executing `npm run migrate`. |
| 15 | +- [ ] Run tests locally executing `npm test`. |
| 16 | + |
| 17 | +## Project Instructions |
| 18 | + |
| 19 | +Dad jokes are all the rage these days! In this challenge, you will build a real wise-guy application. |
| 20 | + |
| 21 | +Users must be able to call the `[POST] /api/auth/register` endpoint to create a new account, and the `[POST] /api/auth/login` endpoint to get a token. |
| 22 | + |
| 23 | +We also need to make sure nobody without the token can call `[GET] /api/jokes` and gain access to our dad jokes. |
| 24 | + |
| 25 | +We will hash the user's password using `bcryptjs`, and use JSON Web Tokens and the `jsonwebtoken` library. |
| 26 | + |
| 27 | +### MVP |
| 28 | + |
| 29 | +Your finished project must include all of the following requirements (further instructions are found inside each file): |
| 30 | + |
| 31 | +- [ ] An authentication workflow with functionality for account creation and login, implemented inside `api/auth/auth-router.js`. |
| 32 | +- [ ] Middleware used to restrict access to resources from non-authenticated requests, implemented inside `api/middleware/restricted.js`. |
| 33 | +- [ ] A minimum of 2 tests per API endpoint, written inside `api/server.test.js`. |
| 34 | + |
| 35 | +**IMPORTANT Notes:** |
| 36 | + |
| 37 | +- Do not exceed 2^8 rounds of hashing with `bcryptjs`. |
| 38 | +- If you use environment variables make sure to provide fallbacks in the code (e.g. `process.env.SECRET || "shh"`). |
| 39 | +- You are welcome to create additional files but **do not move or rename existing files** or folders. |
| 40 | +- Do not alter your `package.json` file except to install extra libraries. Do not update existing packages. |
| 41 | +- The database already has the `users` table, but if you run into issues, the migration is available. |
| 42 | +- In your solution, it is essential that you follow best practices and produce clean and professional results. |
| 43 | +- Schedule time to review, refine, and assess your work and perform basic professional polishing. |
| 44 | + |
| 45 | +## Submission format |
| 46 | + |
| 47 | +- [ ] Submit via Codegrade by pushing commits to your `main` branch on Github. |
| 48 | +- [ ] Check Codegrade before the deadline to compare its results against your local tests. |
| 49 | +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. |
| 50 | +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. |
| 51 | + |
| 52 | +## Interview Questions |
| 53 | + |
| 54 | +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. |
| 55 | + |
| 56 | +1. Differences between using _sessions_ or _JSON Web Tokens_ for authentication. |
| 57 | +2. What does `bcryptjs` do to help us store passwords in a secure manner? |
| 58 | +3. How are unit tests different from integration and end-to-end testing? |
| 59 | +4. How does _Test Driven Development_ change the way we write applications and tests? |
0 commit comments