This is a monorepo containing Cloudflare workers for Jeff Powell's projects.
.
├── .devcontainer/ # Dev environment config and setup
└── workers/
├── jeffpowell-dev/ # Personal portfolio website worker
├── email-register/ # Email alias registration worker
├── email-triage/ # Email routing logic worker
├── tangram-calendar/ # Supplies hints and solutions for tangram puzzle
└── tangram-calendar-submit/ # Submit tangram puzzle hints and solutions
-
Node.js
-
pnpm
-
wrangler
OR
-
Docker
-
VS Code with the Dev Containers extension
If you choose the devcontainer route, you need to follow the alternative login workaround method described later on and provide a .env file. Otherwise the devcontainer will fail to load due to the --env-file call expecting that file to be there.
# Clone the repo
git clone git@github.com:jeffrpowell/jeffpowell.dev.git
cd jeffpowell.dev
# Install all workspace dependencies
pnpm install
# Login to Cloudflare; SEE WORKAROUND NOTES BELOW
pnpm wrangler login --callback-host 0.0.0.0
# Run a worker
cd workers/[worker-name]
pnpm dev #runs a build command, if applicable, then runs wrangler devUntil cloudflare/workers-sdk#10603 and/or cloudflare/workers-sdk#5937 are resolved, you have to perform the following workaround to get wrangler to login:
pnpm wrangler login --callback-host 0.0.0.0- Copy-paste the URL
- Manually change "0.0.0.0" to "localhost"
- Open your modified link in your browser
- Click the
Allowbutton
ALTERNATIVELY
Follow the instructions in .env.example to supply Wrangler with an API token from your account. This will make it so that you do not need to do the manual login step.
Each worker has its own Wrangler version. Navigate to the worker directory to use Wrangler commands:
# Navigate to a worker
cd workers/jeffpowell-dev
# Start local development server
pnpm dev
# Run Wrangler commands directly
pnpm wrangler dev
pnpm wrangler tail
pnpm wrangler whoami
# ... any other wrangler commandDebugging is configured in a VSCode launch.json file for you.
Otherwise, start reading at this trailhead.
If you need to pull down an existing worker to compare or start with, AND you haven't downloaded it already, use this command:
pnpm wrangler --cwd workers init --from-dash [name-of-worker]
It will download to a directory under /tmp/, copy the src files, and then error out looking for a wrangler.toml file. Go manually hunt for the directory and copy the wrangler.jsonc file out of there.
Otherwise, here's the standard recipe for adding a new worker.
- Create a new directory in
workers/:mkdir workers/my-new-worker cd workers/my-new-worker - Initialize with
package.jsonandwrangler.jsonc- Copy from another worker to get a head-start
- The monorepo will automatically include it in workspace commands
This project is open source and available under the MIT License.