
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.
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.
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 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.
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.
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.