Why are database migrations important in a NestJS application using TypeORM?
To manage user sessions
To track and apply changes to the database schema over time
To automatically generate frontend UI components
To handle HTTP requests and responses
What is a common way to implement Role-Based Access Control (RBAC) in NestJS Guards?
By defining access rules in a separate JSON file and parsing it within the Guard.
By using a library like Passport.js to offload all authentication and authorization logic.
By directly embedding complex SQL queries within the Guard's canActivate method.
canActivate
By retrieving user roles from the database and checking if they match the roles required to access the protected route.
What is the primary purpose of custom decorators in NestJS?
To enforce strict type checking at compile time.
To enhance code reusability and readability by encapsulating common logic.
To define custom middleware functions within a controller.
To directly modify the underlying Express.js request and response objects.
What is the typical role of a @SetMetadata decorator when working with custom Guards in NestJS?
@SetMetadata
It defines the structure of the response sent back to the client.
It is used to inject dependencies into Guards.
It directly handles user authentication logic.
It attaches custom metadata to route handlers, which can be accessed within the Guard to make authorization decisions.
What is the primary testing framework used for unit testing in NestJS?
Jest
Chai
Mocha
Jasmine
In TypeORM, what is the purpose of an Entity?
To manage database connections
To define database tables and their columns
To handle HTTP requests
To define routes in a NestJS application
How does NestJS facilitate database integration?
NestJS automatically configures database connections without any additional code
NestJS provides a modular structure and decorators to integrate various database solutions
NestJS only supports relational databases and not NoSQL databases
NestJS prevents the use of external libraries like TypeORM or Mongoose
What is a key benefit of using event subscribers in NestJS?
Centralized management and organization of event listeners
Improved performance for handling a large volume of events
Enhanced type safety when defining event listeners
Automatic retry mechanisms for failed event handlers
Which testing approach in NestJS focuses on verifying the smallest isolated units of code, like individual functions or methods?
Unit Testing
Integration Testing
End-to-End Testing
System Testing
What is a key advantage of using interceptors for cross-cutting concerns like logging and transformation in NestJS?
All of the above
Improved code organization and separation of concerns
Reduced boilerplate code in controllers and services
Enhanced performance and reduced request latency