From 5a7cb4de797d84cbf077ffeac9b47d419dcda10a Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 9 Oct 2022 17:29:31 -0700 Subject: [PATCH] Organize and simplify descriptions --- README.md | 156 ++++++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index a76ac61..7a572b9 100644 --- a/README.md +++ b/README.md @@ -57,92 +57,108 @@ the workspace dependencies first. # Workers +All examples assume that the worker has been deployed at +**`https://x.y.workers.dev`**. + +

Reverse Proxies

+ ## proxy -This is a minimal, basic reverse proxy. +This is a minimal, basic reverse proxy. Proxy any request through the Cloudflare +Worker by passing the **entire** URL as a query string to the Cloudflare Worker. -### 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 - -``` -https://x.y.workers.dev -``` - -and the request you want to proxy is +For example, if the request you want to proxy is: ``` https://api.example.com?param1=test1¶m2=test2 ``` -then the final request URL should be +then the final request URL should be: ``` https://x.y.workers.dev?https://api.example.com?param1=test1¶m2=test2 ``` -### Caching - -For simplicity, this code does not configure the `cf` headers on the `fetch` +For simplicity, this worker 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. - -### Usage - -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](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) response headers +to a response. Useful for using APIs that have not enabled CORS. -### Usage +``` +https://x.y.workers.dev?https://api-with-unconfigured-cors.example.com?param1=test1¶m2=test2 +``` -Same as `proxy`. +## style + +This reverse proxy injects a basic CSS style sheet to a page's `` and +returns the result. Good for quickly "upgrading" old/minimalist web pages with +no styling. + +``` +https://x.y.workers.dev?https://site-with-no-styles.example.com +``` + +

Web Utilities

+ +## qr + +Generates a SVG file representing a QR code for the value passed to the +endpoint. + +``` +https://x.y.workers.dev?https://example.com +> (The SVG file rendered below) +``` + + + +## unroll + +Redirects a Twitter thread to the corresponding Threadreader thread. + +``` +https://x.y.workers.dev?https://twitter.com/{username}/status/{id} +> (HTTP redirect to https://threadreaderapp.com/thread/{id}) +``` + +## instagram + +Returns a page with an Instagram post embedded in it so the post can be viewed +without logging in. + +``` +https://x.y.workers.dev?https://www.instagram.com/p/{POST_ID}/ +> (Page with the Instagram post's embedded view in it) +``` + +

Command Line Utilities

## pwned 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 +is a simplified implementation of the [Pwned Passwords Cloudflare Worker](https://github.com/HaveIBeenPwned/PwnedPasswordsCloudflareWorker). -### Usage +In bash: -Pass a plaintext password as the entire query string to the endpoint. For -example, if your Cloudflare Worker domain is - -``` -https://x.y.workers.dev +```bash +curl https://x.y.workers.dev?hunter2 +> true ``` -and the password you want to check is +In PowerShell: +```powershell +(Invoke-WebRequest https://x.y.workers.dev?hunter2).Content +> true ``` -hunter1 -``` - -then the final request URL should be - -``` -https://x.y.workers.dev?hunter1 -``` - -## qr - -Generates a QR code for the value passed to the endpoint. - -### Usage - -Same as `proxy`. ## ip @@ -151,18 +167,16 @@ Returns the requester's IP address. Uses the `CF-Connecting-IP` to get this value. Inspired by and works like [ifconfig.me](https://ifconfig.me) and [ifconfig.co](https://ifconfig.co). -### Usage - In bash: -``` +```bash curl https://x.y.workers.dev > ``` In PowerShell: -``` +```powershell (Invoke-WebRequest https://x.y.workers.dev).Content > ``` @@ -171,18 +185,16 @@ In PowerShell: Returns a random version 4 UUID. -### Usage - In bash: -``` +```bash curl https://x.y.workers.dev > ``` In PowerShell: -``` +```powershell (Invoke-WebRequest https://x.y.workers.dev).Content > ``` @@ -192,18 +204,16 @@ In PowerShell: Returns the hash of a string using the [crypto web API](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest). -### Usage - In bash: -``` +```bash curl https://x.y.workers.dev?algorithm=SHA-256&query=Hello%2C%20world%21 > 315F5BDB76D078C43B8AC0064E4A0164612B1FCE77C869345BFC94C75894EDD3 ``` In PowerShell: -``` +```powershell (Invoke-WebRequest https://x.y.workers.dev?algorithm=SHA-256&query=Hello%2C%20world%21).Content > 315F5BDB76D078C43B8AC0064E4A0164612B1FCE77C869345BFC94C75894EDD3 ``` @@ -220,19 +230,3 @@ Supported values are: ### `query` (alias `q`) The string you want to get the hash of. - -## style - -Reverse proxy which injects a basic CSS style sheet. - -### Usage - -Same as `proxy`. - -## unroll - -Redirects a tweet thread to the corresponding Threadreader thread. - -### Usage - -Same as `proxy`, but only works on tweet URLs. -- 2.47.3