Install and run
Set up the worker locally with a D1 database, seed data and a running dev server.
You need Node.js 20 or newer and npm. The steps below give you a worker on http://localhost:8787 with a local D1 database and a seeded demo user.
Install dependencies#
npm installnpm install runs wrangler types, which generates worker-configuration.d.ts from wrangler.jsonc and .dev.vars.
Configure secrets#
cp .dev.vars.example .dev.vars.dev.vars holds SECRET_KEY, the HMAC key for login tokens. wrangler dev loads it automatically and never commits it. Set a different value for anything you keep.
Create the database#
npm run db:migrate:local
npm run db:seed:localThe first command applies migrations/*.sql to the local D1 database. The second loads seed.sql: two recipes with ingredients, week 46 with both recipes mapped, one customer review, and the accounts user / password (API user) and alice / password (customer).
Start the worker#
npm run devwrangler serves the worker and the local database. Check it is up:
curl -s http://localhost:8787/healthz{"status":"ok"}Log in#
TOKEN=$(curl -s -X POST http://localhost:8787/api/v1/login -u user:password | jq -r .token)
curl -s http://localhost:8787/api/v1/recipes -H "x-access-tokens: $TOKEN"