Revert to simple object literal pattern (no IIFE, no return)

Simplified to pure object literal expression

Rationale:
- User requested to forget about IIFE wrapper
- Simpler pattern: file evaluates directly to an object
- No function wrapper needed
- No return statement needed
- server.js already handles this correctly at line 59

Pattern:
```javascript
// Define functions at top level
class DocumentCountExceededError extends Error {...}
function generateRequestId() {...}
function parseRoute() {...}

// Final expression evaluates to object
({
  DocumentCountExceededError,
  generateRequestId,
  parseRoute,
  // ... all functions
});
```

How server.js handles it (already correct):
```javascript
const script = new vm.Script(code, { filename: file });
const context = vm.createContext({ ...globalVMContext, ...globalVariableContext });
globalVariableContext[varName] = script.runInContext(context);
// script.runInContext() returns the evaluated expression (the object)
```

Changes:
- Reverted from IIFE with return: (function() { return {...}; })()
- Back to object literal: ({...})
- Removed 2-space indentation throughout
- No function wrapper
- No return statement

Benefits:
 Simplest possible pattern
 Direct object evaluation
 No syntax complexity
 Server.js already handles it correctly
 Clean, minimal code

Testing:
✓ Syntax validated
✓ Server starts successfully
✓ Module loads: 'Loaded global functions: googleDriveAdapterHelper'
✓ All function calls work correctly
✓ Request handling functional

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-03-07 12:22:15 -06:00
parent 07968927fc
commit ab8e43e4ab

View File

@@ -6,7 +6,7 @@
* *
* ARCHITECTURE: * ARCHITECTURE:
* - Loaded by server.js using vm.Script (same as proxy.js) * - Loaded by server.js using vm.Script (same as proxy.js)
* - Function that returns a single object containing all helper functions * - Returns a single object containing all helper functions
* - Injected into globalVariableContext for access by proxy.js * - Injected into globalVariableContext for access by proxy.js
* - NO IMPORTS - All dependencies provided via VM context * - NO IMPORTS - All dependencies provided via VM context
* *
@@ -17,7 +17,6 @@
* @returns {Object} Helpers object with all utility functions * @returns {Object} Helpers object with all utility functions
*/ */
(function() {
/** /**
* Custom error for document count exceeding limit * Custom error for document count exceeding limit
*/ */
@@ -282,11 +281,12 @@
// All other paths return 404 // All other paths return 404
return { route: null, error: "Not found", statusCode: 404 }; return { route: null, error: "Not found", statusCode: 404 };
} }
// ============================================================================= // =============================================================================
// Return helpers object with all functions // Return helpers object with all functions
// ============================================================================= // =============================================================================
return { ({
// Error classes // Error classes
DocumentCountExceededError, DocumentCountExceededError,
@@ -309,5 +309,4 @@
// Routing // Routing
parseRoute, parseRoute,
}; });
})();