
Explore a solid Node.js REST API architecture using Express and MongoDB, including middleware validation, controllers, services, and reusable data access patterns, plus Swagger documentation.
Install MongoDB by downloading the community server, selecting the operating system, and running the installer, then verify the installation with the MongoDB shell and logs.
Demo the tools we will use in the course, including the commander terminal for Windows, and provide steps to download these tools to mirror the setup.
Overview of section
Explore how promises differ from async/await and see how await eliminates callback hell, enhances readability, and simplifies error handling with try/catch.
Discover the api overview for a Node.js rest api with Express and MongoDB, implementing jwt authentication, product endpoints (create, list, get by id, delete), and a layered middleware-controller-service architecture.
Set up a basic node.js server using express, initialize npm, and install dotenv for environment variables. Configure a root route and run with nodemon for automatic restarts.
Explore express middlewares, from application-level to router-level, learn how to use next, mount on app or path, and implement built-in json and urlencoded, error handling, and cors with practical examples.
Connect your node app to mongodb using mongoose, define a connectivity module, call connect with local host database name, and handle success or error logs for reliable data access.
Define a product model in Mongoose with a product schema including name, price, and brand, export the model, and enable timestamps for createdAt and updatedAt.
Learn how to use Mongoose's toObject transform to customize document output by removing _id and __v, renaming fields, and returning a clean front-end friendly object.
Define a product API schema using joy to validate incoming payloads in a Node.js Express app, enforce required fields, and return errors via middleware before reaching controllers.
Implement Joi schema validation middleware in a Node.js Express API to validate request bodies against the product schema before hitting the controller, and return structured error details on invalid input.
Develop a get all products API with pagination (skip and limit) in a Node.js, Express, and MongoDB architecture, using a controller, a service, and a helper to format MongoDB data.
Learn to implement a get product by id API using a path parameter, with controller and service, Mongoose id validation, and error handling for not found or invalid id.
Update a product via a put API using path parameter for the product id and a request body with optional fields, using schema validation and returning the updated document.
Implement a signup API with Node.js, Express, and MongoDB. Define a user model with email and password, hash the password, check duplicates, validate input with Joi, and omit the password.
Build a post login API with express that validates login data, compares plain text passwords to hashed values, and issues a JWT with the user id as payload.
Protect your product routes by implementing a token validation middleware that verifies JWTs from the authorization header and passes control to the controller on success.
Learn to build and test robust API documentation with Swagger in a Node.js Express app, detailing endpoints, payloads, parameters, responses, models, and JWT authentication.
Examine the source code for a Node.js REST API built with Express and MongoDB. Explore solid architecture practices for scalable backend design.
Want to learn how to build REST API with Nodejs, Express, and MongoDB ?? If yes, then this course is for you. In this course you will learn how to create MVC pattern REST API architecture in Nodejs, communication with MongoDB using Mongoose, Securing API with JWT ( JSON web token) and documenting API using popular open-source tool called swagger.
We are in the world of REST API architecture because of the boom in the micro-services. Every company is moving toward REST API architecture from traditional monolithic server architecture.
What is REST API ?
A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.
Why MVC Pattern in REST API ?
MVC pattern/architecture allows you to decouple your code into various modules such as controller, services, models and routes so that you can scale your code without any burden of code maintenance as all the nodes in the MVC architecture works in sync and as expected.
You will be learning the following things in this course:
♦ REST API in Nodejs and Express.
♦ MVC Architecture in REST API Nodejs.
♦ Interaction with MongoDB in nodejs using mongoose.
♦ Create, update, delete and find query using mongoose.
♦ Create pagination API using mongoose pagination query in Nodejs.
♦ Secure REST API with JSONWEBTOKEN ( JWT ).
♦ Use tools such as POSTMAN to test API.
♦ Write middleware in Nodejs .
♦ Joi object schema validation in Nodejs.
♦ Host swagger documentation of your REST API on your API server itself.
♦ Create Re-usable services in REST API.
♦ Enable Cross-Origin Resource Sharing (CORS) in Nodejs REST API.
♦ Mongoose schema and models.
♦ HTTP request basics: Request body, path params, query params, and headers.
♦ CRUD API in Nodejs.
♦ Login/Authenticate API to generate a token.
♦ REST API Design.
♦ Node and NPM.
♦ and more.