Instruction file imported from Thereallo1026/fetch-worker (
.cursor/rules/code-organization.mdc). Copyright stays with the author.
Code Organization
Architecture
The fetch worker is organized into logical components:
- Entry Point: src/index.ts - Sets up the worker and routes requests
- Request Handler: src/handlers/requestHandler.ts - Processes incoming requests
- Fetch Executor: src/handlers/fetchExecutor.ts - Executes fetch requests using provided configuration
- Utilities: src/utils/corsHeaders.ts - Common utilities like CORS headers
Flow
- Request received at the worker
- Request validated and parsed
- Fetch operation executed using the provided configuration
- Response formatted and returned with appropriate CORS headers
Development Tips
- Add new utilities in the src/utils/ directory
- Extend handler functionality in src/handlers/
- Configure worker settings in wrangler.jsonc