0
0
NestJSframework~30 mins

Hybrid applications in NestJS - Mini Project: Build & Apply

Choose your learning style9 modes available
Building a Hybrid Application with NestJS
📖 Scenario: You are creating a simple NestJS application that can run both as a REST API server and as a GraphQL server. This hybrid setup allows your app to serve different types of clients easily.
🎯 Goal: Build a NestJS hybrid application that sets up both REST and GraphQL modules and starts the server with both capabilities.
📋 What You'll Learn
Create a NestJS application instance
Configure a REST controller
Configure a GraphQL module
Use the app.select() method to create a hybrid app
Start the application listening on port 3000
💡 Why This Matters
🌍 Real World
Hybrid applications let you serve different client needs from one backend, like mobile apps using REST and web apps using GraphQL.
💼 Career
Understanding hybrid apps with NestJS is useful for backend developers building flexible APIs that support multiple protocols.
Progress0 / 4 steps
1
Create the NestJS application instance
Write code to create a NestJS application instance called app using NestFactory.create(AppModule).
NestJS
Need a hint?

Use NestFactory.create(AppModule) to create the app instance.

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

Use const port = 3000; inside the bootstrap function.

3
Create the hybrid application with REST and GraphQL modules
Use app.select() to select AppModule and create a hybrid app instance called hybridApp.
NestJS
Need a hint?

Use const hybridApp = app.select(AppModule); to create the hybrid app.

4
Start the hybrid application listening on the port
Call hybridApp.listen(port) to start the server on port 3000.
NestJS
Need a hint?

Use await hybridApp.listen(port); to start the server.