Added new feature for document export, including API contracts, data model, implementation plan, and tests. Updated related configurations and instructions.
This commit is contained in:
@@ -281,9 +281,64 @@ Follow-up TODOs:
|
||||
- All dependencies injected through `vm.createContext({ ... })` context object
|
||||
- VM isolation prevents access to require(), import(), fs, process, and Node.js globals
|
||||
|
||||
#### I.0 Forbidden Globals in proxy.js (NON-NEGOTIABLE)
|
||||
|
||||
`src/proxyScripts/proxy.js` MUST NOT access ANY infrastructure configuration globals. The following are **ABSOLUTELY PROHIBITED**:
|
||||
|
||||
- ❌ `config` - Infrastructure settings (server port, proxy paths, logging level)
|
||||
- ❌ `global.config` - Global configuration object
|
||||
- ❌ `process.env` - Environment variables (these are server concerns, not business logic)
|
||||
|
||||
**ONLY the following globals are permitted** in `src/proxyScripts/proxy.js`:
|
||||
|
||||
- ✅ `console` - Custom logger (injected by server.js)
|
||||
- ✅ `crypto` - Web Crypto API for randomUUID()
|
||||
- ✅ `axios` - HTTP client for API calls
|
||||
- ✅ `jwt` - JSON Web Token library for authentication
|
||||
- ✅ `xmlBuilder` - XML document builder
|
||||
- ✅ `uuidv4` - UUID generator
|
||||
- ✅ `googleDriveAdapterHelper` - Helper functions (loaded from src/globalVariables/)
|
||||
- ✅ `google_drive_settings` - Business data only (service account, Drive query, sitemap settings)
|
||||
- ✅ `req` - HTTP request object (includes req.params with routing metadata)
|
||||
- ✅ `res` - HTTP response object
|
||||
|
||||
**Rationale**: Infrastructure configuration (server ports, proxy routing, deployment settings) is the responsibility of server.js, NOT business logic. proxy.js implements document export logic - it should NOT know about HTTP server configuration, proxy path prefixes, or deployment details. These are injected via `req.params` when needed for routing.
|
||||
|
||||
**If routing information is needed** (e.g., proxy path prefix for route parsing):
|
||||
1. server.js MUST parse the incoming request URL
|
||||
2. server.js MUST extract routing metadata (workspaceId, branch, routeName)
|
||||
3. server.js MUST add this to `req.params` before invoking proxy.js
|
||||
4. proxy.js accesses routing info via `req.params`, NOT via `config`
|
||||
|
||||
**Example of correct routing metadata injection**:
|
||||
```javascript
|
||||
// server.js - BEFORE invoking proxy.js
|
||||
if (global.config.proxy) {
|
||||
const { pathPrefix, workspaceId, branch, routeName } = global.config.proxy;
|
||||
const fullPrefix = `${pathPrefix.replace(/\/$/, '')}/${workspaceId}/${branch}/${routeName}`;
|
||||
|
||||
if (req.url.startsWith(fullPrefix)) {
|
||||
req.params = {
|
||||
"0": req.url, // Original path
|
||||
workspaceId, // Extracted from config
|
||||
branch, // Extracted from config
|
||||
route: routeName // Extracted from config (renamed to 'route')
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Enforcement**:
|
||||
- Any reference to `config` in proxy.js MUST be rejected
|
||||
- Any reference to `global.config` in proxy.js MUST be rejected
|
||||
- Any reference to `process.env` in proxy.js MUST be rejected
|
||||
- Routing metadata MUST be passed via `req.params`, never via `config`
|
||||
- Code reviews MUST verify zero infrastructure globals in proxy.js
|
||||
|
||||
#### I.I What MUST Be in src/proxyScripts/proxy.js
|
||||
|
||||
|
||||
|
||||
The following MUST be implemented in `src/proxyScripts/proxy.js` (or extracted to googleDriveAdapterHelper.js if pure utilities):
|
||||
|
||||
1. **Authentication**: Service Account JWT, OAuth flows, token management (MUST be in proxy.js)
|
||||
|
||||
Reference in New Issue
Block a user