This tutorial shows how to build a Leaderboard API At Edge using Cloudflare Workers and Redis.
npm install -g @cloudflare/wrangler
Authenticate: wrangler login
or wrangler config
Then create a project: wrangler generate edge-leaderboard
Open wrangler.toml
. Run wrangler whoami
and copy/paste your account id to
your wrangler.toml.
Find your REST token from database details page in the
Upstash Console. Copy/paste your token to your
wrangler toml as below:
wrangler dev
. It will give you a local URL. You can
test your API with curl:
Add new scores:
webpack
wrangler publish
. Wrangler will output the URL. If you want to
deploy to a custom domain see
here.