Complete developer guide for contributing to this project or creating your own version to run on Cloudflare Workers using Wrangler.
Note: this project does not include a package.json, and it does not require any npm dependencies.
The project provides a pre-configured Dev Container environment for GitHub Codespaces, making it quick and easy to start coding.
Using Codespaces is the recommended way to work on the project because it automatically sets up the required elements and provides a ready-to-code environment.
Before you start a new Codespaces environment and begin coding in it, you need to register the required secrets in the repository's GitHub Codespaces Secrets.
See the environment variables section for the required configuration and the GitHub Codespaces secrets documentation for more details.
Open the repository on GitHub and create a new Codespace from the Code → Codespaces menu.
GitHub will automatically detect the project's .devcontainer.json configuration and build the development environment.
The .devcontainer.json file defines the complete development environment:
-
Ubuntu-based development container
-
Node.js 24
-
Cloudflare Wrangler
-
Required environment variables
-
Generated TypeScript definitions for Cloudflare Worker bindings
The setup is executed automatically when the Codespace is created via postCreateCommand. The Codespace is created with environment variables that are automatically read from the Codespaces environment and written to .dev.vars by the dev container setup, Wrangler is installed, and types are initialized.
Wrangler is intentionally installed globally inside the Codespace to keep the repository free of Node.js project dependencies.
Note:
.dev.varsis a local development file and must never be committed to the repository. It's already been added to the.gitignore.
Once the Codespace has finished initializing, authenticate Wrangler with your Cloudflare account:
wrangler loginReview the wrangler.jsonc file, which contains the complete project configuration:
Defines the Worker project name.
This determines your public URL (e.g., https://project-name.your-subdomain.workers.dev).
Specifies the entry point of your Worker script. This file exports your main fetch handler.
Locks your Worker to a specific Cloudflare Workers runtime version. Ensures compatibility even as Cloudflare updates the platform.
Enables or disables preview URLs for testing.
true= Enables preview URLsfalse= Disables preview URLs
For more details: https://developers.cloudflare.com/workers/configuration/previews/
When true, enables automatic metrics and logs collection.
Allows performance and error monitoring in the Cloudflare dashboard.
Defines the percentage of requests sampled for tracing (0 to 1):
1= 100% sampling (useful for debugging)0.1= 10% sampling (better for production)
Controls automatic invocation log collection:
true= Logs request metadata, headers, and execution detailsfalse= Disables automatic logs, keeping only customconsole.logentries
Disabling invocation logs is recommended for GDPR compliance to prevent storage of sensitive request data.
Controls distributed tracing:
true= Enables tracing spans and trace IDsfalse= Disables tracing entirely
Leave disabled if not using OpenTelemetry or a tracing system.
The Worker uses environment variables for local development and Cloudflare secrets for production.
| Variable | Description |
|---|---|
HASH_KEY |
Cryptographic key for hashing user IP addresses |
Create/configure the following value as GitHub Codespaces secrets. When the Codespace is created, .devcontainer.json automatically writes it to .dev.vars:
HASH_KEY="THE_KEY_USED_TO_HASH_IPS"For the deployed Worker, configure the same value as Cloudflare Workers secrets:
wrangler secret put HASH_KEYFor more details: https://developers.cloudflare.com/workers/configuration/secrets/
Software configuration: config.ts
export const config: StaticConfig = {
RATE_LIMIT_INTERVAL_S: 1, // Min: 1
MAX_RANDOM_METEORITES: 1000, // Min: 100
MAX_RETURNED_SEARCH_RESULTS: 500, // Min: 100
MIN_RADIUS: 1, // Min: 1
MAX_RADIUS: 2500, // Min: 1000
DEFAULT_RANDOM_NUMBER_OF_METEORITES: 100 // Min: 100
};| Parameter | Description | Constraints |
|---|---|---|
RATE_LIMIT_INTERVAL_S |
Rate limit interval in seconds | Minimum: 1s |
MAX_RANDOM_METEORITES |
Maximum meteorites returned by /random |
Minimum: 100 |
MAX_RETURNED_SEARCH_RESULTS |
Maximum meteorites returned by /search |
Minimum: 100 |
MIN_RADIUS |
Minimum allowed search radius (km) | Minimum: 1km |
MAX_RADIUS |
Maximum allowed search radius (km) | Minimum: 1000km |
DEFAULT_RANDOM_NUMBER_OF_METEORITES |
Default count for /random if not specified |
Minimum: 100 |
Important:
MAX_RANDOM_METEORITESmust always be greater thanDEFAULT_RANDOM_NUMBER_OF_METEORITES. If this condition is not met, the configuration will produce errors.
Once your Codespace is ready and your Cloudflare account is authenticated, you're ready to start coding, but some explanation of TypeScript types and the running process will be provided in this section.
The Dev Container automatically runs wrangler types when the Codespace is created, generating the Worker bindings in worker-configuration.d.ts (there are no bindings in this project at the moment).
If you change your Wrangler configuration or bindings, regenerate the definitions manually with:
wrangler typesEnsure
wrangler.jsoncis properly configured before regenerating the types.
This generates TypeScript type definitions, which are already included in tsconfig.json:
{
"compilerOptions": {
"noEmit": true,
"allowImportingTsExtensions": true,
"target": "ES2020",
"lib": [
"ES2020",
"DOM"
],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"types": [
"./worker-configuration.d.ts"
],
"resolveJsonModule": true
},
"include": [
"utilities",
"worker-configuration.d.ts",
"main.ts",
"config.ts",
"types"
],
"exclude": [
"node_modules",
"dist"
]
}| Setting | Purpose |
|---|---|
noEmit: true |
Prevents TypeScript from emitting JS locally; Wrangler handles bundling |
allowImportingTsExtensions: true |
Allows direct .ts file imports for relative paths |
target: "ES2020" |
Uses modern JavaScript syntax supported by Workers runtime |
lib: ["ES2020", "DOM"] |
Includes modern JS features and Web APIs (fetch, Request, Response) |
module: "ESNext" |
Uses ES Modules standard for Workers |
moduleResolution: "Bundler" |
Configures module resolution for bundler-based ESM environments |
strict: true |
Enables all strict type checking for safer code |
esModuleInterop: true |
Facilitates CommonJS interoperability |
skipLibCheck: true |
Skips type checking for .d.ts files to speed up compilation |
forceConsistentCasingInFileNames: true |
Prevents file casing errors across operating systems |
types: ["./worker-configuration.d.ts"] |
Includes Wrangler binding type definitions |
resolveJsonModule: true |
Allows importing JSON files as modules |
include |
Source files and types to type check |
exclude |
Build artifacts and dependencies to ignore |
wrangler devMake sure your Cloudflare Workers secrets have been configured before deploying. See environment variables.
wrangler deployIf the Worker is configured with a workers.dev deployment, Wrangler will display the deployed URL.
For issues or questions, open an issue on GitHub.
{ "name": "project-name", "main": "main.ts", "compatibility_date": "2026-03-08", "preview_urls": false, "observability": { "enabled": true, "head_sampling_rate": 1, "logs": { "invocation_logs": false }, "traces": { "enabled": false } } }