@nrwl/nest

Nest.js is a framework designed for building scalable server-side applications. In many ways, Nest is familiar to Angular developers:
- It has excellent TypeScript support.
- Its dependency injection system is similar to the one in Angular.
- It emphasises testability.
- Its configuration APIs are similar to Angular as well.
Many conventions and best practices used in Angular applications can be also be used in Nest.
Setting Up Nest
To create a new workspace with Nest, run the following command:
1npx create-nx-workspace my-workspace --preset=nestYarn users can use the following command instead:
1yarn create nx-workspace my-workspace --preset=nestTo add the Nest plugin to an existing workspace, run one the following commands:
1npm install -D @nrwl/nest1yarn add -D @nrwl/nestCreate Applications
You can add a new Nest application with the following command:
1nx g @nrwl/nest:app my-nest-appApplication Proxies
Generating Nest applications has an option to configure other projects in the workspace to proxy API requests. This can be done by passing the --frontendProject with the project name you wish to enable proxy support for.
1nx g @nrwl/nest:app my-nest-app --frontendProject my-angular-appCreate Libraries
You can add a new Nest library with the following command:
1nx g @nrwl/nest:lib my-nest-libTo make the library buildable, use the following command:
1nx g @nrwl/nest:lib my-nest-lib --buildableTo make the library publishable, use the following command:
1nx g @nrwl/nest:lib my-nest-lib --publishable --importPath=@my-workspace/my-nest-libRead more about building and publishing libraries here.
Nest Generators
The Nest plugin for Nx extends the generators provided by Nest. Any commands that can be used with the Nest CLI can also be used with the nx command. The --project flag should be used for all Nest generators.
--projectis used to infer the root of the project where the generators will generate the files.
Using Nest
Build
You can build an application with the following command:
1nx build my-nest-appThis applies to buildable libraries as well
1nx build my-nest-libWaiting for other builds
Setting the waitUntilTargets option with an array of projects (with the following format: "project:architect") will execute those commands before serving the Nest application.
Serve
You can serve an application with the following command:
1nx serve my-nest-appThe serve command runs the build target, and executes the application.
By default, the serve command will run in watch mode. This allows code to be changed, and the Nest application to be rebuilt automatically.
Debugging
Nest applications also have the inspect flag set, so you can attach your debugger to the running instance.
Debugging is set to use a random port that is available on the system. The port can be changed by setting the port option in the serve architect in the workspace.json. Or by running the serve command with --port <number>.
For additional information on how to debug Node applications, see the Node.js debugging getting started guide.
Lint
You can lint an application with the following command:
1nx lint my-nest-appYou can lint a library with the following command:
1nx lint my-nest-libUnit Test
You can run unit test for an application with the following command:
1nx test my-nest-appYou can run unit test for a library with the following command:
1nx test my-nest-libMore Documentation
Package reference
Here is a list of all the executors and generators available from this package.
Executors
Generators
Create a NestJS application.
Convert a project from TSLint to ESLint.
Initialize the
@nrwl/nestplugin.Create a new NestJS library.
Run the
classNestJS generator with Nx project support.Run the
controllerNestJS generator with Nx project support.Run the
decoratorNestJS generator with Nx project support.Run the
filterNestJS generator with Nx project support.Run the
gatewayNestJS generator with Nx project support.Run the
guardNestJS generator with Nx project support.Run the
interceptorNestJS generator with Nx project support.Run the
interfaceNestJS generator with Nx project support.Run the
middlewareNestJS generator with Nx project support.Run the
moduleNestJS generator with Nx project support.Run the
pipeNestJS generator with Nx project support.Run the
providerNestJS generator with Nx project support.Run the
resolverNestJS generator with Nx project support.Run the
resourceNestJS generator with Nx project support.Run the
serviceNestJS generator with Nx project support.