Convention: What is the correct pattern for @Controller() paths in backe...
Documentation for Sessions
📏 Convention: What is the correct pattern for @Controller() paths in backe...
Date: 2026-02-20
Time: 19:28:38 UTC
Session: gspace1-129.3
Agent: backend
Confidence: 100%
Status: ✅ Documented
📋 Decision Context
Question:
What is the correct pattern for @Controller() paths in backend-api?
Task: Establish convention for NestJS controller paths
🎯 Decision Made
Chosen:
NEVER include 'api/' in @Controller() decorator paths. Use paths relative to the global prefix. Example: @Controller('spaces/:spaceId/files') resolves to /api/spaces/:spaceId/files because main.ts has setGlobalPrefix('api').
Options Considered:
- Include api/ in @Controller() path (WRONG - causes double prefix)
- Use paths relative to global prefix (CORRECT)
- Remove setGlobalPrefix and add api/ to every controller (unnecessarily verbose)
💭 Reasoning
backend-api/src/main.ts line 56-57 sets globalPrefix = 'api' via app.setGlobalPrefix(). This applies /api to ALL routes automatically. If a controller also includes 'api/' in its path, the result is /api/api/... which is wrong. This bug has been introduced TWICE (Session 31 for global-modules, Session 52.2 for platform-users/space-files/mocks/generated-modules) by developers unaware of the global prefix. The same convention applies to all 4 backends: backend-api uses 'api', backend-ai-api uses 'ai-api', backend-docs-api uses 'docs-api', backend-vitto-api uses 'vitto-api'.
📁 Files Involved
apis/backend-api/src/main.tsapis/backend-ai-api/src/main.tsapis/backend-docs-api/src/main.tsapis/backend-vitto-api/src/main.ts
🔗 Related
- Decision ID:
dev_1771615718826_91zwmqb - Session: 129
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation