A small notes application built with Cloudflare Workers and D1.
npm install
npm startOpen http://127.0.0.1:8787.
Unit and browser tests both run through:
npx playwright install chromium
npm testThis runs:
npm run test:unitfor API and storage testsnpm run test:e2efor Playwright browser coverage against a local Wrangler instance
After deployment, npm run smoke:live runs a minimal check against the live site.
Basic workflow:
- Create a note
- Select it from the list
- Edit the current version
- Save a new version
- Use Undo, Redo, or Restore to move through note history
web/index.htmlentire frontendworker/index.jsentire Worker and storage logicworker/0001_init.sqlinitial D1 migrationwrangler.jsoncCloudflare and Wrangler configuration
Wrangler is the command-line tool used to run and deploy the app.
npm startrunswrangler dev- Wrangler reads
wrangler.jsonc mainpoints toworker/index.jsassets.directorypoints toweb/d1_databasesbinds the D1 database toenv.DB
At runtime:
- Requests to
/api/*go to the Worker - Non-API requests are served from the static files in
web/ - The Worker uses
env.DBto read and write note data in D1
For deployment:
npm run deploypublishes the Worker and static assetsnpm run migrateapplies the numbered migration files inworker/to the remote D1 database
This repo includes:
.github/workflows/ci.ymlto run tests on pull requests and non-mainpushes.github/workflows/deploy.ymlto test, deploy, and apply migrations on pushes tomain
Required GitHub repository secrets:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_ID
Production data lives in the remote Cloudflare D1 database identified by database_id in wrangler.jsonc.
- Deploying the Worker does not delete D1 data
- Notes and versions stay in D1 between deploys and restarts
npm run migrateonly applies new numbered SQL migrations, which is the intended path for schema changes