Complete the code to import the core module in a NestJS application.
import { [1] } from '@nestjs/common';
The Module decorator is used to define a module in NestJS, which is essential for organizing the application structure.
Complete the code to create a basic controller in NestJS.
@Controller('[1]') export class AppController {}
The @Controller('app') decorator defines a controller with the route prefix 'app'.
Fix the error in the provider registration to ensure production readiness.
@Module({
providers: [[1]],
})
export class AppModule {}Providers like AppService should be registered in the providers array to be injectable and used properly.
Fill both blanks to configure environment variables and enable validation for production readiness.
import { [1] } from '@nestjs/config'; @Module({ imports: [[2].forRoot({ isGlobal: true })], }) export class AppModule {}
ConfigModule is imported and configured globally to manage environment variables, which is key for production readiness.
Fill all three blanks to set up a global validation pipe and enable CORS for production readiness.
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new [1]());
app.enableCors({ origin: [2] });
await app.listen([3]);
}The ValidationPipe ensures input validation globally. Enabling CORS with origin '*' allows all origins. Listening on port 3000 is a common default.