From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Introduction to Nest middlewares

Introduction to Nest middlewares

In building any backend application, middlewares are essential and important. They are not a unique concept specific to NestJS though. Middlewares are used throughout every single backend application, regardless of the language or framework. It is a very common practice to utilize middleware and that is why it is also important that one should know how to use them along with NestJS as well. Middlewares are generally used for request handling by providing a way to intercept the incoming HTTP request, execute some logic, and then either pass the request to the next middleware or return a response. Now before we get into implementing a middleware, let me quickly explain what exactly a middleware is. Let's assume that we have a client that makes a request. And on the back end side, specifically with NestJS, there is a controller that handles the request and sends a response to the client. So this is a general request response pattern, followed by the client and the server or Nest…

Contents