@nrwl/express

Express Logo

Express is mature, minimal, and an open source web framework for making web applications and apis.

Setting Up Express

To create a new workspace with Express, run the following command:

1 npx create-nx-workspace --preset=express
2

Adding Express to an Existing Project

Install the express plugin

1npm install --save-dev @nrwl/express
2
1yarn add --dev @nrwl/express
2

Creating Applications

Add a new application to your workspace with the following command:

1nx g @nrwl/express:app my-app
2

Serve the application by running

1nx serve my-app
2

This starts the application on localhost:3333/api by default.

Express does not come with any library generators, but you can leverage the@nrwl/js plugin to generate a Node.js library for your express application.

Application Proxies

The Express application generator 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/express:app <express-app> --frontendProject my-react-app
2

Using Express

Testing Projects

You can run unit tests with:

1nx test <project-name>
2

Building Projects

Express projects can be built with:

1nx build <project-name>
2

Build artifacts will be found in the dist directory under apps/<project-name> by default. Customize the build configuration by editing outputPath in the project configuration.

Waiting for Other Tasks

You can wait for other tasks to run before serving the express app which can be handy for spinning up various services the application depends on— for example, other apis in a microservice.

Setting the waitUntilTargets option with an array of targets (format: "project:target") executes those tasks before serving the Express application.

More Documentation

Package reference

Here is a list of all the executors and generators available from this package.

Executors

Generators

  • init

    Initialize the @nrwl/express plugin.

  • application

    Create an Express application.