NOTE This project uses
wrangler@v1.x.x
.wrangler@v2.x.x
was released 1st May 2022, check out the comparison here.
flowchart TD
api_clients([API Clients])
browser([Browser])
server(<a href='https://developers.cloudflare.com/workers/'>API Server</a>):::cf
kgs(<a href='https://developers.cloudflare.com/workers/'>Key Generation Service</a>):::cf
key_db[(<a href='https://developers.cloudflare.com/workers/runtime-apis/kv/'>KEY_DB</a>)]:::cf
paste_db[(<a href='https://developers.cloudflare.com/workers/runtime-apis/kv/'>PASTE_DB</a>)]:::cf
classDef cf stroke:#FFC500,stroke-width:2px
subgraph Cloudflare
server
kgs
key_db
paste_db
end
key_db <--> server
kgs <--> key_db
server <--> api_clients
server <--> browser
paste_db <--> server
Paste Story is a Pastebin clone — a web service that allows users to share text content through a link known as 'pastes'.
“Why Pastebin?” you might ask. Well, sending 50 lines long block of text through a chat app isn’t exactly the best way to communicate.
- Get a Cloudflare account
- Install Wrangler CLI for Cloudflare Workers deployment
Check out Steps 1 to 3 of this Get Started Guide to setup a Cloudflare account.
Run make install
.
Check out the following:
Since we're using KV as our storage, we need to first create it.
# Production namespace:
wrangler kv:namespace create "PASTE_DB"
wrangler kv:namespace create "KEY_DB"
# This namespace is used for `wrangler dev` local testing:
wrangler kv:namespace create "PASTE_DB" --preview
wrangler kv:namespace create "KEY_DB" --preview
For creating these KV namespaces, remember to update your wrangler.toml
files of the respective service to include the namespace bindings accordingly.
-
This project uses Wrangler actions to automatically publish worker. To do so, add
CF_API_TOKEN
into your GitHub repository secrets. You can create your API token using theEdit Cloudflare Workers
template. -
This project also uses semantic-release to automatically publish to NPM. To enable this, you will need to create a
NPM_TOKEN
via npm create token and add it to your GitHub repository secrets.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Fork this
- Create your feature branch (
git checkout -b tom/fooBar
) - Code
- Commit your changes (
git commit -am 'feat: add some fooBar'
, make sure that your commits are semantic) - Push to the branch (
git push origin tom/fooBar
) - Create a new Pull Request