Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 1.4 KB

File metadata and controls

79 lines (57 loc) · 1.4 KB

retroactive-compensation-cf-worker

An API for a retroactive compensation system, built with Cloudflare Workers and Cloudflare D1.

Used template for Cosmos wallet authentication to authenticate requests via a Cosmos wallet signature.

Read through the design spec here.

Development

Run locally

npm run dev
# OR
wrangler dev --local --persist

Configuration

  1. Copy wrangler.toml.example to wrangler.toml.

  2. Create KV namespaces for production and development:

wrangler kv:namespace create NONCES
wrangler kv:namespace create NONCES --preview
  1. Update the binding IDs in wrangler.toml:
kv-namespaces = [
  { binding = "NONCES", id = "<INSERT NONCES_ID>", preview_id = "<INSERT NONCES_PREVIEW_ID>" }
]
  1. Create D1 database for production:
wrangler d1 create DB
  1. Update the binding ID in wrangler.toml:
[[ d1_databases ]]
binding = "DB"
database_name = "DB"
database_id = "<INSERT DB_ID>"
  1. Seed the database with:
npm run seed
# OR
wrangler d1 execute DB --file=./schema.sql
  1. Seed the local database with:
npm run seed:local
# OR
wrangler d1 execute DB --file=./schema.sql --local

Deploy

wrangler publish
# OR
npm run deploy