Monorepo
Scaffolding a Nest.js App with REST, GraphQL, Cron, and Message Brokers
Last updated
Scaffolding a Nest.js App with REST, GraphQL, Cron, and Message Brokers
Last updated
In medium and large-scale projects, we often need more than just REST and GraphQL. Frequently, there is a need to run commands on a schedule. Additionally, service applications, such as queue consumers, play a significant role in the architecture.
This gives us a total of four types of applications that may be required:
REST Application: A standard API application that runs a web server, typically listening on port 80.
GraphQL Application: A dedicated server for handling GraphQL queries, implemented using any JavaScript GraphQL library.
Console Application: Used for executing scheduled tasks, such as with cron jobs or systemd-timers.
Service Applications: Applications dedicated to consuming messages from a queue system. While all types of applications can act as message producers, service applications specifically operate as consumers.
The number and types of applications you need will depend on the scale and complexity of your project.
Visually, this can be represented as follows:
Make sure you have the Nest CLI or just install it.
Command nest new name
- Scaffolds a new standard mode application with all boilerplate files needed to run.
Command nest generate sub-app name
Convert this to a monorepo mode.
So great, now we have 4 rest apps . Let's check the result.