Bird
0
0

What is a key characteristic of functional middleware in NestJS?

easy📝 Conceptual Q1 of 15
NestJS - Middleware
What is a key characteristic of functional middleware in NestJS?
AIt is a simple function that takes request, response, and next parameters
BIt must be a class decorated with @Injectable()
CIt automatically handles exceptions without next()
DIt can only be used with GraphQL modules
Step-by-Step Solution
Solution:
  1. Step 1: Understand functional middleware signature

    Functional middleware in NestJS is a plain function that accepts three parameters: request, response, and next.
  2. Step 2: Compare with other middleware types

    Unlike class-based middleware, functional middleware does not require decorators or class structure.
  3. Final Answer:

    It is a simple function that takes request, response, and next parameters -> Option A
  4. Quick Check:

    Functional middleware = simple function [OK]
Quick Trick: Functional middleware is just a function with req, res, next [OK]
Common Mistakes:
  • Thinking functional middleware must be a class
  • Assuming it handles errors automatically
  • Believing it only works with GraphQL

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes