A production-ready Node.js Express API starter with shared libraries, module boundary enforcement, and Docker support - built for teams who want structure from day one.
🚀 If you haven't connected to Nx Cloud yet, complete your setup here. Get faster builds with remote caching, distributed task execution, and self-healing CI. See how your workspace can benefit.
npx create-nx-workspace@latest my-workspace --template nrwl/express-api-templatenpx create-nx-workspace@latest my-api --preset=express --appName=api --docker=true --nxCloud=skip# Install dependencies
npm install
# Start dev server (watch mode)
npx nx run @express-api-template/api:serve
# Build for production
npx nx run @express-api-template/api:build
# Run all builds
npx nx run-many -t build
# Run tests
npx nx run-many -t test
# Visualize the project graph
npx nx graphAPI is available at http://localhost:3333 with these routes:
| Method | Path | Description |
|---|---|---|
| GET | /api/health | Health check + uptime |
| GET | /api/items | List all items |
| POST | /api/items | Create an item |
| GET | /api/items/:id | Get one item by ID |
| DELETE | /api/items/:id | Delete an item by ID |
# Build production image (runs prune + copy-workspace-modules first)
npx nx run @express-api-template/api:docker:build
# Run the container
docker run -p 3333:3333 express-api-template:latestexpress-api-template/
- apps/
- api/ # Express application (scope:api, type:app)
- src/
- controllers/ # Route handlers (health, items)
- routes/ # Express Router definitions
- main.ts # Entry point
- Dockerfile # Multi-stage production image
- api-e2e/ # End-to-end tests
- packages/
- util/ # Shared utility library (scope:shared, type:util)
- src/lib/util.ts # ApiResponse type + helper fns
The @express-api-template/util library exports typed response helpers used across the API:
import { successResponse, errorResponse, notFoundResponse } from '@express-api-template/util';
res.json(successResponse({ id: 1, name: 'Widget' }));
// -> { success: true, data: { id: 1, name: 'Widget' }, timestamp: '...' }Nx caches every task output locally. Re-run npx nx run @express-api-template/api:build instantly after a clean run - it replays from cache. With Nx Cloud the cache is shared across your whole team.
Only rebuild what changed:
# Test only what's affected by your branch
npx nx affected -t test
# Lint only affected projects
npx nx affected -t lintESLint rules in eslint.config.mjs enforce the dependency graph via tags:
type:utillibs can only depend on othertype:utillibstype:appapps can depend on any lib type- Violations fail
nx lintimmediately, no runtime surprises
Add a new lib with tags and the rules enforce automatically:
npx nx g @nx/js:lib packages/db --bundler=tsc --tags="scope:api,type:data-access"- Inferred
build,serve,test,linttargets from config prune-lockfile+copy-workspace-modulestargets for lean Docker images- Hot-reload dev server for local development
# Add another Express app
npx nx g @nx/express:app apps/admin
# Add a data-access lib
npx nx g @nx/js:lib packages/db --bundler=tsc --tags="scope:api,type:data-access"
# Add a utility lib
npx nx g @nx/js:lib packages/config --bundler=tsc --tags="scope:shared,type:util"Nx Cloud makes CI fast and reliable.
- Remote cache - Every build/test result is stored in a shared cache. A PR that only touches
packages/utilwon't rebuild the API app - Nx replays the cached output in milliseconds. - Distributed task execution (DTE) - Large workspaces can split tasks across multiple CI agents automatically. The project graph determines what can run in parallel, and Nx Cloud orchestrates the distribution.
- Flaky task detection - Nx Cloud tracks task run history. When a test flakes it is flagged, automatically retried, and reported - so you know which tests need fixing vs which failures are real regressions.
Connect: npx nx connect -> https://cloud.nx.app
Learn more at https://nx.dev/nx-cloud.
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
- Nx Documentation
- Crafting Your Workspace Tutorial
- Module Boundaries
- Express Documentation
- Docker Integration
- Nx Cloud
Join the Nx community: