Nx Project Management
Project Naming Convention
- Applications: Direct name (e.g.,
auth-server,migration-runner) - Libraries:
{domain}-{name}format (e.g.,server-jwt,infra-db,shared-errors)
Library Domains
| Domain | Path | Tag |
| ----------------- | ----------------------------- | ---------------------- |
| fastify/plugins | libs/fastify/plugins/{name} | scope:fastify-plugin |
| infra | libs/infra/{name} | scope:infra |
| server | libs/server/{name} | scope:server |
| shared | libs/shared/{name} | scope:shared |
Module Boundaries
| Source Tag | Only Depend On |
| --------------- | -------------------------------------------------------------- |
| scope:shared | scope:shared |
| type:testing | scope:shared, scope:infra, scope:server, scope:fastify |
| scope:infra | scope:infra, scope:shared |
| scope:server | scope:server, scope:shared |
| scope:fastify | scope:fastify, scope:server, scope:infra, scope:shared |
| scope:app | scope:fastify, scope:shared, scope:server-config |
Creating New Libraries
ALWAYS use Nx generators. NEVER create libraries manually.
pnpm nx generate @nx/js:library \
--name={name} \
--directory=libs/{domain}/{name} \
--projectNameAndRootFormat=as-provided \
--importPath=@qauth-labs/{domain}-{name} \
--bundler=none \
--linter=none \
--unitTestRunner=none \
--no-interactive
Examples
# Server library
pnpm nx generate @nx/js:library \
--name=auth \
--directory=libs/server/auth \
--projectNameAndRootFormat=as-provided \
--importPath=@qauth-labs/{domain}-{name} \
--bundler=none \
--linter=none \
--unitTestRunner=none \
--no-interactive
# Fastify plugin
pnpm nx generate @nx/js:library \
--name=auth \
--directory=libs/fastify/plugins/auth \
--projectNameAndRootFormat=as-provided \
--importPath=@qauth-labs/{domain}-{name} \
--bundler=none \
--linter=none \
--unitTestRunner=none \
--no-interactive
After Generation
- Add tags to
project.json:
```json
"tags": ["scope:{domain}", "type:{type}"]
```
- Update
index.tsexports
- Verify path alias in
tsconfig.base.json
Project Tags
scope:app- Application projectsscope:fastify-plugin- Fastify pluginsscope:infra- Infrastructure librariesscope:server- Server-side librariesscope:shared- Shared utilitiestype:db- Database-relatedtype:cache- Cache-related
Viewing Projects
pnpm nx show project {project-name}
pnpm nx graph
pnpm nx show projects