National Commerce Docs
ShipHero Handler

Configuration & Deployment

Environment secrets, Wrangler config, Sentry, and the auto-deploy flow for the ShipHero Handler worker.

The worker is a standard Cloudflare Workers project managed with Wrangler. This page covers its secrets, its config, and how it ships.

Environment variables

All values are stored as Cloudflare Worker secrets and read from c.env at runtime. The worker itself does not use a .env file.

SecretPurpose
SUPABASE_URLSupabase project URL
SUPABASE_KEYSupabase API key
SHIPHERO_SKU_RETRIEVAL_URLn8n webhook used for the SKU fallback lookup
SENTRY_DSNSentry error-tracking DSN
ZONE_CALC_API_KEYAPI key for the National Commerce zone calculator
VERIFY_QUANTITIESOptional. Set to "false" to disable quantity verification

Add or update a secret with Wrangler:

npx wrangler secret put SECRET_NAME

Backfill scripts use a different key

The standalone backfill scripts run outside the worker and read a local .env file with SUPABASE_SERVICE_ROLE_KEY (the elevated service-role key), not the worker's SUPABASE_KEY.

Wrangler config

wrangler.jsonc defines the worker:

  • name: shiphero-handler
  • main: src/index.ts
  • compatibility_date: 2025-04-08
  • compatibility_flags: nodejs_compat
  • observability is enabled, with head_sampling_rate: 1 (100% of requests are traced)

TypeScript runs in strict mode and uses Hono's JSX runtime (jsxImportSource: "hono/jsx").

Error tracking

The entire Hono app is wrapped with Sentry.withSentry. The Sentry config sets sendDefaultPii: true (request headers and IP are attached) and tracesSampleRate: 1.0. Uncaught errors in the handler surface in Sentry as well as in the Cloudflare logs.

Local development

npm install
npm run dev      # wrangler dev

npm run dev starts the worker locally with Wrangler. There is no test suite. Changes are verified by replaying webhooks against a running worker.

Deployment

Do not deploy manually

The repository is connected to Cloudflare through the GitHub integration. Pushing commits triggers an automatic deploy. Do not run npm run deploy / wrangler deploy by hand.

To ship a change: commit, push, and let Cloudflare deploy the latest commit.

Regenerating Supabase types

When the database schema changes, regenerate src/utils/supabase/types.ts:

npx supabase gen types typescript --project-id axzbddunsdtgjpnycprb > src/utils/supabase/types.ts

The generated file carries every table, enum, and relationship the worker needs for type-safe queries.

Supabase tables the worker touches

TableRole
BrandsHolds the ShipHero access token; keyed by n8n_id
WarehousesLooked up by Warehouse_ID; supplies the warehouse ZIP
OrdersOrder records with financial fields
ShipmentsShipment tracking, box, and zone data
Shipment Line ItemsIndividual items within a shipment
Product SKUsProduct SKU catalog
End Customer (Amazon buyer)Customer records from shipping addresses
StoresStore / shop records created from shop_name

On this page