---
title: "Discussion on \"Turbocharge Your Nest.js App with Interceptors\" | Hashnode"
description: "Discussion on \"Turbocharge Your Nest.js App with Interceptors\". Unlock Advanced Functionality in your APIs"
url: "https://hashnode.com/posts/turbocharge-your-nestjs-app-with-interceptors/648457135acdb3f6fa9d5594"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Turbocharge Your Nest.js App with Interceptors](https://blog.jean-marc.io/turbocharge-your-nestjs-app-with-interceptors?utm_source=hashnode&utm_medium=feed)

Unlock Advanced Functionality in your APIs

Jun 10, 2023 · 19 min read · blog.jean-marc.io  
Read the article

-   [#nestjs](https://hashnode.com/tag/nestjs)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#apis](https://hashnode.com/tag/apis)
-   [#development](https://hashnode.com/tag/development)

## Written by

[Jean-Marc Möckel](https://hashnode.com/@jean-marc5592)

@jean-marc5592 · Germany

  
[View profile](https://hashnode.com/@jean-marc5592)

Fullstack Javascript Developer

## Responses 1

Markdown supported · ⌘↵ to post

[Костя Третяк](https://hashnode.com/@ktretiak)

[Aug 1, 2023](https://hashnode.com/posts/turbocharge-your-nestjs-app-with-interceptors/648457135acdb3f6fa9d5594/comment/64c97bbee5834aa8ddb70771)

It is not clear why you use interceptors for security instead of guards.

[Jean-Marc Möckel](https://hashnode.com/@jean-marc5592)

[Aug 2, 2023](https://hashnode.com/posts/turbocharge-your-nestjs-app-with-interceptors/648457135acdb3f6fa9d5594/comment/64c97bbee5834aa8ddb70771#reply-64ca5903fc5843b339eb9b1d)

Yeah you're right, but in general guards in Nest.js are also some kind of interceptors because you get access to the request, check certain things and decide if you wanna pass the request through or block it. That's why I first talked about interceptors in general and then go into details in Nest. When you have an express application without the concepts of guards you would probably use interceptors for that concept as well. Makes sense?

[Костя Третяк](https://hashnode.com/@ktretiak)

[Aug 2, 2023](https://hashnode.com/posts/turbocharge-your-nestjs-app-with-interceptors/648457135acdb3f6fa9d5594/comment/64c97bbee5834aa8ddb70771#reply-64ca7495218e67b3098f5694)

[Jean-Marc Möckel](https://hashnode.com/@jean-marc5592), yes, I agree that guards can be considered a subset of interceptors, but NestJS does not guarantee that a particular interceptor will necessarily be called first (before any other interceptors). And this is a problem.

[Jean-Marc Möckel](https://hashnode.com/@jean-marc5592)

[Aug 15, 2023](https://hashnode.com/posts/turbocharge-your-nestjs-app-with-interceptors/648457135acdb3f6fa9d5594/comment/64c97bbee5834aa8ddb70771#reply-64db3a4d6203e95780d656f4)

[Костя Третяк](https://hashnode.com/@ktretiak) Yeah but you can control it because even with interceptors you can create a certain hierarchy. Global Interceptors -> Module Interceptors -> Route Interceptors. With leveraging that you can control to a certain degree which interceptor should be called first. But I get your point. This can sometimes lead to some issues because you don't want to run a globally implemented interceptor in all cases.
