0
0
NestJSframework~30 mins

Why NestJS exists - See It in Action

Choose your learning style9 modes available
Understanding Why NestJS Exists
📖 Scenario: You are a developer learning backend frameworks. You want to understand why NestJS was created and what problems it solves compared to plain Node.js or other frameworks.
🎯 Goal: Build a simple NestJS project that shows the basic setup and a simple controller to demonstrate the framework's structure and purpose.
📋 What You'll Learn
Create a basic NestJS application structure
Add a configuration variable for the port number
Create a simple controller with one route
Complete the main application bootstrap code
💡 Why This Matters
🌍 Real World
NestJS is used to build backend servers for web and mobile apps, APIs, and microservices with a clean and maintainable structure.
💼 Career
Many companies use NestJS for scalable Node.js backend development, so understanding why it exists helps in writing better server-side code and working in teams.
Progress0 / 4 steps
1
Create the basic NestJS application structure
Create a NestJS application by importing NestFactory from @nestjs/core and a root module called AppModule as an empty class.
NestJS
Need a hint?

Start by importing NestFactory and define an empty class named AppModule.

2
Add a configuration variable for the port number
Add a constant variable called PORT and set it to 3000 to configure the server port.
NestJS
Need a hint?

Use const PORT = 3000; to set the port number.

3
Create a simple controller with one route
Create a controller class called AppController with a method getHello that returns the string 'Hello from NestJS!'. Use the @Controller() decorator and @Get() decorator from @nestjs/common.
NestJS
Need a hint?

Use @Controller() above the class and @Get() above the method that returns the greeting string.

4
Complete the main application bootstrap code
Write an async function called bootstrap that creates the NestJS app with NestFactory.create(AppModule), listens on PORT, and call bootstrap() at the end.
NestJS
Need a hint?

Use an async function to create and start the NestJS app on the port.