✨ Your new, shiny Nx workspace is almost ready ✨.
Learn more about this workspace setup and its capabilities or run npx nx graph
to visually explore what was created. Now, let's get you up to speed!
To run the dev server for your app, use:
Example :npx nx serve gateway
To create a production bundle:
Example :npx nx build gateway
To see all available targets to run for a project, run:
Example :npx nx show project gateway
These targets are either inferred automatically or defined in the project.json
or package.json
files.
More about running tasks in the docs »
While you could add new projects to your workspace manually, you might want to leverage Nx plugins and their code generation feature.
Use the plugin's generator to create new projects.
To generate a new application, use:
Example :npx nx g @nx/nest:app xxx
To generate a new library, use:
Example :npx nx g @nx/node:lib xxx
You can use npx nx list
to get a list of installed plugins. Then, run npx nx list <plugin-name>
to learn about more specific capabilities of a particular plugin. Alternatively, install Nx Console to browse plugins and generators in your IDE.
Learn more about Nx plugins » | Browse the plugin registry »
Layer | Description |
---|---|
interface-adapters | It should not contain complex business logic. Responsible for receiving and processing requests from clients. These requests are interactions with external systems that need to be converted into operations that conform to the business logic through adapters. Relies on the Application layer for core business logic, avoiding direct interaction with databases or other external systems. |
resolver(interface-adapters) | Handles GraphQL queries and mutations by converting them into calls to the application layer. Responsible for input validation and response formatting specific to GraphQL. |
dto(interface-adapters) | Define DTOs for GraphQL schema. |
infrastructure | Implements the technical capabilities needed to support the higher layers of the application. Handles database connections, external service integrations, and other technical concerns. Contains concrete implementations of repository interfaces defined in the domain layer. |
mongoose(infrastructure) | Implements the repository interfaces defined in the domain layer using Mongoose as the ODM (Object Document Mapper). Includes Mongoose Schema definitions, database connection management, and concrete implementations of repository interfaces (e.g., MongooseUsersRepository). Adding validation in the Mongoose schema ensures that any data persisted to the database adheres to the required constraints. This helps maintain data integrity and prevents invalid or duplicate entries at the database level. |
service(application) | As the core of the application layer, it mainly interacts with the domain layer and interface-adapter layer. If you migrate to a non-NestJS architecture in the future (e.g. other frameworks or microservices), the application tier code can be left unaffected. |
use-case(application) | Define business use cases and encapsulate business logic. Implementing validation in the use-case layer allows you to enforce business logic and provide immediate feedback to users or calling services. This is where you can handle complex validation rules and provide detailed error messages. |
entity(domain) | Define core business entities and business rules. Maintain entity independence from database and framework. |
repository(domain) | Interfaces (or abstract classes), which define methods for manipulating data without concern for specific database implementations. By defining this interface, we can decouple database access: the specific details of data access will be done by implementation classes, such as specific implementations using tools like Mongoose, TypeORM, Prisma, and so on. |
Move a project to another folder in the workspace:
nx g @nx/workspace:move --project xxx --destination root/xxx/xxx
Learn more:
And join the Nx community: