0
0
NestJSframework~20 mins

Why NestJS exists - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
NestJS Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why was NestJS created?
NestJS was created to solve which main problem in Node.js backend development?
ATo provide a structured and scalable architecture for building server-side applications
BTo replace JavaScript with a new programming language
CTo simplify database management by removing the need for ORMs
DTo create a frontend framework for building user interfaces
Attempts:
2 left
💡 Hint
Think about what developers struggle with when building large backend apps in Node.js.
component_behavior
intermediate
2:00remaining
What does NestJS provide out of the box?
Which feature is a core part of NestJS that helps developers write clean backend code?
ADependency injection system to manage class dependencies automatically
BBuilt-in frontend templating engine for UI rendering
CAutomatic CSS styling for web pages
DReal-time chat server without any configuration
Attempts:
2 left
💡 Hint
Think about how NestJS helps manage how classes get their needed parts.
📝 Syntax
advanced
2:30remaining
Which code snippet correctly defines a NestJS controller?
Choose the option that shows a valid NestJS controller class with a GET route.
A
import { Controller, Get } from '@nestjs/common'

@Controller('cats')
class CatsController {
  @Get
  findAll() {
    return 'All cats';
  }
}
B
import { Controller, Get } from '@nestjs/common';

@Controller('cats')
export function CatsController() {
  @Get()
  function findAll() {
    return 'Cats list';
  }
}
C
import { Controller, Get } from '@nestjs/common';

@Controller('cats')
export class CatsController {
  @Get()
  findAll() {
    return 'This action returns all cats';
  }
}
D
import { Controller, Get } from '@nestjs/common';

@Controller('cats')
export class CatsController {
  findAll() {
    return 'Cats';
  }
}
Attempts:
2 left
💡 Hint
Look for correct use of decorators and class syntax.
lifecycle
advanced
2:30remaining
When is the NestJS module lifecycle hook 'onModuleInit' called?
At what point in the NestJS application lifecycle does the 'onModuleInit' method run?
AOnly when the application shuts down
BRight after the module's providers have been instantiated but before the app starts listening
CBefore any modules or providers are created
DAfter every HTTP request is handled
Attempts:
2 left
💡 Hint
Think about when initialization logic for a module should run.
🔧 Debug
expert
3:00remaining
Why does this NestJS service fail to inject the dependency?
Given this service code, why will NestJS throw a runtime error about missing dependency? ```typescript import { Injectable } from '@nestjs/common'; import { CatsRepository } from './cats.repository'; @Injectable() export class CatsService { constructor(private catsRepo: CatsRepository) {} } ``` Options:
AThe constructor parameter should be public, not private
BCatsService is missing the @Controller decorator
CCatsRepository must be imported from '@nestjs/common' to work
DCatsRepository is not marked with @Injectable(), so NestJS cannot inject it
Attempts:
2 left
💡 Hint
Check if the dependency class is properly decorated for injection.