Rebasely Beta: data may be purged

examples/storefront Public

Markdown · 51 lines · 1.9 KiB · at e83464e

---id: local-devtype: guideowner: justindescribes:  - wrangler.jsonc  - workers/*/wrangler.jsonc  - scripts/seed.sqlreviewed: 2026-10-15---# Running the shop locallyYou need Node 24 and, for checkout, a Stripe account in test mode. Everything else runs in wrangler's local mode.## The API```bashnpm installnpm run db:migrate          # applies migrations/ to the local D1npm run db:seed             # six products, one of them out of stockecho 'ADMIN_TOKEN=dev-admin-token' > .dev.varsnpm run dev                 # storefront-api on localhost:8787````curl localhost:8787/products` lists all six; the candle is out of stock, so adding it to a cart fails. Checkout needs the payments Worker running too, with a Stripe test mode secret key.Image URLs point at `IMAGES_URL` from `wrangler.jsonc`. Locally the upload works but the URL does not resolve, because the custom domain serves the production bucket ([[product-images]]). Set `IMAGES_URL` in `.dev.vars` to another origin if you want working links.## The other WorkersEach has its own config, so run it in a second terminal from the repository root:```bashnpx wrangler dev -c workers/payments/wrangler.jsonc --port 8788npx wrangler dev -c workers/fulfilment/wrangler.jsonc --port 8789```Each Worker reads its secrets from a `.dev.vars` next to its config: `STRIPE_SECRET_KEY` and `STRIPE_WEBHOOK_SECRET` for payments, `WAREHOUSE_URL` and `WAREHOUSE_TOKEN` for fulfilment. wrangler connects the service bindings between the running Workers (`PAYMENTS` one way, `ORDERS` the other), and the `order-events` queue between storefront-api and fulfilment. See [[payment-webhook]] for forwarding Stripe's test events and [[fulfilment]] for the warehouse settings.## CronThe unpaid order expiry runs on a cron trigger. To run it once by hand:```bashnpx wrangler dev --test-scheduledcurl 'localhost:8787/__scheduled?cron=*/5+*+*+*+*'```## TestsThe tests need none of this; see [[testing]].