Monorepo for my personal [Cloudflare Workers](https://workers.cloudflare.com/).
-Uses [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) (npm version 7+) to manage multiple `package.json` files (a separate package is required for each Cloudflare Worker).
-3. Authorize yourself with your Cloudflare account
-```
-npm run login
-```
+3. For each Cloudflare Worker, make a copy of `wrangler.toml.example` and rename
+ it to `wrangler.toml`.
+ [Customize the fields](https://developers.cloudflare.com/workers/wrangler/configuration/)
+ as required.
-4. For each Cloudflare Worker, make a copy of `wrangler.toml.example` and rename it to `wrangler.toml`. Set `account_id` in `wrangler.toml`:
-```
-account_id = [Account ID value from login]
-```
+4. Test that each Cloudflare Worker works:
-5. Test that all Cloudflare Workers work:
```
-npm run preview --workspaces
+npm run dev --workspace=[Cloudflare Worker name]
```
-Or test an individual Worker:
-```
-npm run preview --workspace=[Cloudflare Worker name]
-```
+5. Publish all the Workers to Cloudflare:
-6. Publish all the Workers to Cloudflare:
```
npm run publish --workspaces
```
Or publish an individual Worker:
+
```
npm run publish --workspace=[Cloudflare Worker name]
```
# Limitations
-There are [some permission issues](https://github.com/cloudflare/wrangler/issues/240) when installing `wrangler` as a dependency in an npm workspace. As a workaround, I've made `wrangler` a dependency in the top-level `package.json` for the overall monorepo, and omitted `wrangler` from the dependencies for each workspace. That means that **the npm scripts in each workspace depend on `wrangler` being installed outside of the workspace**. So if you wanted to pull a workspace out of the monorepo and run the workspace on its own, you must re-add `wrangler` to the workspace dependencies first.
+There are
+[some permission issues](https://github.com/cloudflare/wrangler/issues/240) when
+installing `wrangler` as a dependency in an npm workspace. As a workaround, I've
+made `wrangler` a dependency in the top-level `package.json` for the overall
+monorepo, and omitted `wrangler` from the dependencies for each workspace. That
+means that **the npm scripts in each workspace depend on `wrangler` being
+installed outside of the workspace**. So if you wanted to pull a workspace out
+of the monorepo and run the workspace on its own, you must re-add `wrangler` to
+the workspace dependencies first.
# Workers
@@ -58,34+63,46 @@ This is a minimal, basic reverse proxy.
### Usage
-Proxy any request through the Cloudflare Worker by passing the **entire** URL as a query string to the Cloudflare Worker. So if your Cloudflare Worker domain is
+Proxy any request through the Cloudflare Worker by passing the **entire** URL as
+a query string to the Cloudflare Worker. So if your Cloudflare Worker domain is
-For simplicity, this code does not configure the `cf` headers on the `fetch` request that is sent to the Cloudflare proxy. Set the `cf` request headers to configure the Cloudflare Worker's behavior on caching. See: [Cache using fetch](https://developers.cloudflare.com/workers/examples/cache-using-fetch).
+For simplicity, this code does not configure the `cf` headers on the `fetch`
+request that is sent to the Cloudflare proxy. Set the `cf` request headers to
+configure the Cloudflare Worker's behavior on caching. See:
+[Cache using fetch](https://developers.cloudflare.com/workers/examples/cache-using-fetch).
## instagram
-This reverse proxy embeds Instagram posts so they can be viewed without logging in.
+This reverse proxy embeds Instagram posts so they can be viewed without logging
+in.
### Usage
-Same as `proxy`, but it will only work on instagram URLs in the format: `https://www.instagram.com/p/{POST_ID}/`.
+Same as `proxy`, but it will only work on instagram URLs in the format:
+`https://www.instagram.com/p/{POST_ID}/`.
## cors
-This reverse proxy injects permissive CORS response headers to a response. Useful to use APIs that have not enabled CORS.
+This reverse proxy injects permissive CORS response headers to a response.
-Checks a password against the [have i been pwned?](https://haveibeenpwned.com/) API and returns a boolean indicating if the password has been pwned or not. This is a simplified re-implementation of the [Pwned Passwords Cloudflare Worker](https://github.com/HaveIBeenPwned/PwnedPasswordsCloudflareWorker).
+Checks a password against the [have i been pwned?](https://haveibeenpwned.com/)
+API and returns a boolean indicating if the password has been pwned or not. This
-Returns the requester's IP address. Uses the [Cloudflare header](https://developers.cloudflare.com/workers/runtime-apis/headers#cloudflare-headers) `CF-Connecting-IP` to get this value. Inspired by and works like [ifconfig.me](https://ifconfig.me) and [ifconfig.co](https://ifconfig.co).