MERN quiz creator app Part 2: Creating a database, Creating a basic api, adding JWT authentication.
Summary
TLDRIn this episode of the MERN stack series, the creator embarks on building a quiz app with a React frontend and Node.js backend from scratch. The tutorial covers setting up middleware, configuring CORS, and using body-parser for request handling. It dives into integrating MongoDB for database management, setting up image uploading with Cloudinary, and creating custom middleware for JWT authentication. The video also details user model creation, user registration, login functionality, and user retrieval, ensuring secure and authenticated access to the app's features.
Takeaways
- π The video is part of a MERN stack series focusing on building a quiz app from scratch, including deployment and database setup.
- π οΈ The app will have a React frontend and a Node.js backend, with features like image uploading and JWT authentication.
- πΌ The creator shares personal experience, mentioning how building and deploying apps has helped secure a job offer despite being only 19.
- π§ Middleware setup is discussed, including setting up CORS and body-parser for handling requests and parsing JSON bodies.
- π The importance of setting environment variables for services like MongoDB, Cloudinary, and JWT secrets is highlighted.
- π The process of creating a MongoDB database and setting up a free cluster on MongoDB's website is explained.
- πΈ Cloudinary is introduced as an easy-to-use image uploading service, with instructions on how to set up an account and retrieve API keys.
- π The video covers creating custom middleware for JWT validation to ensure secure and authenticated requests.
- π The creation of user models and routes for registration, login, and user retrieval is detailed, emphasizing best practices in validation and security.
- π The script includes a troubleshooting moment where the creator identifies and fixes an error related to undefined values in the request body.
- π The episode concludes with the successful setup of user registration, login, and retrieval endpoints, along with JWT authentication.
Q & A
What is the purpose of the MERN stack series in this video?
-The purpose of the MERN stack series in this video is to create a quiz app with a React front end and Node.js back end, from scratch, including deployment, database setup, and image uploading.
What benefits does the speaker claim about the quiz app project?
-The speaker claims that the quiz app project is a great addition to one's portfolio and can almost guarantee getting a job, as it showcases skills that are rare among non-senior developers.
What is middleware in the context of this video?
-In the context of this video, middleware refers to functions that run every time the server gets a request, allowing the server to perform certain tasks before handling the request.
What is CORS and why is it considered a developer's worst nightmare by the speaker?
-CORS (Cross-Origin Resource Sharing) is a security feature that restricts web applications from making requests to a domain different from the one that served the web page. The speaker considers it a developer's worst nightmare because it can be difficult to handle and is often seen as a hindrance in web development.
Why does the speaker choose to set a high limit for the body parser middleware?
-The speaker sets a high limit for the body parser middleware to accommodate larger image uploads, although it's noted that this is not a best practice and a more calculated estimate should be used in production.
What is the role of the 'check auth' middleware in the project?
-The 'check auth' middleware is used to validate JWT (JSON Web Tokens) to ensure that they are signed by the server with the app secret, providing a secure way to verify user authentication.
Why does the speaker recommend setting up a Cloudinary account for image uploading?
-The speaker recommends Cloudinary because it is an easy-to-use service for image uploading that simplifies the process compared to setting up AWS for small projects.
What is the significance of the 'app secret' in the context of JWTs?
-The 'app secret' is used to sign the JWTs, allowing the server to verify that the token came from the correct client and ensuring its authenticity.
What is the purpose of the 'users' model in the script?
-The 'users' model defines the schema for the user data in the MongoDB database, including fields like first name, last name, email, and password, with validation rules for each field.
How does the speaker plan to implement user registration and login functionality?
-The speaker plans to implement user registration and login functionality by creating endpoints in the 'users' routes file, using bcrypt for password hashing, and JWT for authentication.
What is the role of the 'check off' middleware in user authentication?
-The 'check off' middleware is used to check if the JWT provided by the user is valid and if it was issued by the server, ensuring that the user is authenticated before allowing access to protected routes.
Outlines
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowMindmap
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowKeywords
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowHighlights
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowTranscripts
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowBrowse More Related Video
Learn JWT in 10 Minutes with Express, Node, and Cookie Parser
Authorization & Authentication | Login & Register System In Laravel | Laravel For Beginners
Laravel 11 Multi Auth For Ecommerce Website | Step By Step
JWT Authentication with Node.js, React, MySQL | Node JS Authentication With JSON Web Token
# 1 MERN Project Series | Intro to Food Delivery App & Brief on MERN Stack | Hindi 2023
All about Firebase Authentication π₯ | Login & Signup | Jetpack Compose
5.0 / 5 (0 votes)