Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-seo-audit-1777280932.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Creating Services and Libraries
The CoW Protocol BFF monorepo uses NX generators to scaffold new projects with proper TypeScript, Docker, and configuration setup.Available Generators
Three main generators are available:| Command | Purpose |
|---|---|
yarn new:fastify | REST API services |
yarn new:node | Background workers, CLI tools |
yarn new:lib | Shared libraries |
Fastify API Services
- App configuration (
src/app/app.ts) - Entry point (
src/main.ts) - Docker setup
- ESLint settings
- Testing infrastructure
Route Organization
Keep route schemas in separate files (e.g.,*.schemas.ts). Do not inline JSON schemas in route handlers.
Post-Generation Steps
- Add the new service to
docker-compose.ymlwith appropriate networking and environment configuration - Update CI/CD pipeline configurations
- Configure environment variables
Node.js Applications
- Background workers
- Message queue consumers
- Scheduled jobs
- CLI tools
Bootstrap Pattern
Applications typically include graceful shutdown handling:Shared Libraries
Post-Generation Setup
- TypeScript path alias - Register in
tsconfig.base.json:
- Public API - Define exports in
src/index.ts:
- Module boundaries - Follow these rules:
- Apps can import from libs
- Libs should only import from other libs
- Never create circular dependencies
Existing Libraries
The monorepo includes these shared libraries:| Library | Purpose |
|---|---|
@cowprotocol/repositories | Data access layer |
@cowprotocol/services | Business logic |
@cowprotocol/shared | Utilities and types |
@cowprotocol/notifications | Notification templates |
@cowprotocol/abis | Smart contract ABIs |
Architecture Enforcement
NX enforces module boundaries to maintain clean architecture:- Apps can import from libs
- Libs should only import from other libs
- Circular dependencies are prevented