Commit Graph

11 Commits

Author SHA1 Message Date
d6fa0b1f97 Refactor: Store helpers in globalVariableContext instead of separate variable
Changes:
- Store helpers object in globalVariableContext.helpers
- Remove separate 'helpers' variable and helpersContext
- Helpers now spread into context via ...globalVariableContext
- Simplifies context injection - all globals in one place

Benefits:
- More consistent with JSON data loading pattern
- Single source of truth (globalVariableContext) for all VM globals
- Cleaner context creation (no separate helpers variable)
- helpers treated same as other global objects

Implementation:
- loadHelpers() now mutates globalVariableContext instead of returning
- Use tempContext for helpers execution (discarded after use)
- helpers accessible as 'helpers' in proxy.js via spread operator

Testing:
- ✓ Syntax validated
- ✓ helpers accessible in VM context
- ✓ Spread operator includes both JSON data and helpers
- ✓ All 11 helper functions available

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 11:00:17 -06:00
ab5aa83b6f Update server.js to load and inject helpers module
Changes:
- Add loadHelpers() function to load helpers.js via vm.Script
- Load helpers module at startup using same isolation pattern as proxy.js
- Inject helpers object into VM context for proxy.js access
- Update paths: global/ → globalVariables/, proxy.js → proxyScripts/proxy.js
- Create isolated context for helpers with crypto and console

Implementation:
- helpers.js loaded via vm.Script with isolated context
- helpers context includes crypto and console (logger)
- helpers object returned by IIFE execution
- Injected into per-request VM context alongside other globals
- Follows constitution pattern for vm.Script module loading

Testing:
- ✓ All JavaScript syntax validated
- ✓ Helpers module loads successfully
- ✓ All 11 expected functions present
- ✓ generateRequestId() returns valid format

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 10:55:17 -06:00
b263311a43 Extract helper functions from proxy.js into helpers.js module
- Create src/globalVariables/helpers.js (315 lines)
- Extract 11 pure utility functions from proxy.js
- Reduce proxy.js from 752 to 493 lines (35% reduction)
- Load helpers via vm.Script with same isolation pattern
- Update constitution to document helper extraction pattern

Extracted functions:
- generateRequestId, validateDocumentId, validateDocumentCount
- escapeXml, mapDriveErrorToHttp
- toSitemapEntry, transformDocumentsToSitemapEntries
- generateSitemapXML, generateSitemap
- parseRoute, DocumentCountExceededError class

Architecture:
- helpers.js loaded via vm.Script (IIFE returning object)
- Injected as 'helpers' global object into VM context
- proxy.js accesses via helpers.functionName() pattern
- Maintains zero-import isolation pattern

Constitution version: 1.16.0 → 1.17.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 10:52:49 -06:00
f6710203c7 Reorganize project structure: relocate proxy.js and global directory
- Move src/proxy.js → src/proxyScripts/proxy.js
- Move global/ → src/globalVariables/
- Update constitution.md to reflect new file locations
- Update all documentation references to new paths
- Consolidate all source code under src/ directory

Constitution version: 1.15.0 → 1.16.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 10:35:03 -06:00
c2ecc72775 removed .old files 2026-03-07 01:36:41 -06:00
b35a5c82ce bringing inline with code 2026-03-07 01:35:07 -06:00
a9406d4292 remove globalThis and added URL to global 2026-03-07 01:29:07 -06:00
1a6bd09b7b Now working as a vm.Script passing in all the Globals the proxy script needs 2026-03-07 01:20:45 -06:00
67b36f97ce trying to stop proxy.js from exporting 2026-03-07 00:02:46 -06:00
e9495f65b5 Initial Version of sitemap.xml spec 2026-03-06 23:34:00 -06:00
fec5bfa5c7 Initial commit from Specify template 2026-03-05 23:44:06 -06:00