How can you create a custom provider in NestJS that provides a value instead of a class?
By using the @FactoryProvider() decorator.
@FactoryProvider()
By using the @ValueProvider() decorator.
@ValueProvider()
By using the @ClassProvider() decorator.
@ClassProvider()
By using the @Injectable() decorator.
@Injectable()
Which decorator is used to define an Interceptor class in NestJS?
@Interceptor()
@Controller()
@Module()
What is the purpose of dependency injection in NestJS?
To manage database connections.
To handle errors gracefully.
To define the application's routing logic.
To provide a mechanism for creating and injecting dependencies into classes.
Which decorator is used to mark a class as a provider in NestJS?
@Service()
Can a Controller access a Service's methods in NestJS?
Yes, by injecting the Service into the Controller's constructor.
No, Controllers and Services are completely isolated.
Only if the Controller and Service are defined in the same module.
Yes, by using static methods of the Service.
What is the primary programming language used for developing NestJS applications?
C#
Python
JavaScript
Java
How can you access the currently logged-in user within your middleware in NestJS?
By querying the database directly within the middleware.
By injecting the Request object into the middleware function.
Request
By accessing the req.user object, assuming you have an authentication middleware set up.
req.user
By using the user property of the Response object.
user
Response
After installing the NestJS CLI, what command is used to initiate a new NestJS project?
npm init nestjs-app
nest new project-name
nestjs create-app my-app
create-react-app my-nestjs-project
What is the role of Providers in NestJS?
To handle data persistence.
To define the application's entry point.
To provide dependencies that can be injected into other components like controllers or services.
To render UI elements.
In a typical NestJS project structure, which directory commonly houses the application's source code?
/src
/public
/node_modules
/dist