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.

Excluding routes

Excluding routes

When we want to exclude certain routes from having the middleware applied on them, we can easily do that by using the exclude method. Let's understand it practically. Previously, we tried to exclude the post route by giving this syntax where we specified the route method dot get to target all the get routes and exclude the rest. Now let's try to exclude the post route with the help of the exclude method. It follows the same syntax that is path property, I will set it to route 4 and the method property where I give the request method dot post. So this is how we can exclude a particular route. Now in the for routes method, I will simply update the path without any properties. Let's try this out. I'll open the postman, we'll change the method type to post and give the slash route for in the path. the content type is set to application slash JSON. Let's make the request and the content type is returned. Now let's change the content type to application slash JavaScript and make the…

Contents