dde53319e5
- New custom server.js (replaces react-router-serve): ISO timestamps on all console.* output and on access logs, and skip successful /healthz polls so real traffic stays visible. - New ProcessedWebhook table + dedupe helper keyed on X-Shopify-Webhook-Id; stops Shopify retries from triggering a second invoice email when the original delivery exceeded the 5s ack timeout. - orders/create + orders/fulfilled now respond 200 immediately and run the PDF/email work in the background so we stay under that timeout. - pickLanguage(): non-German locales (it, fr, es, ...) now default to English instead of falling back to German. Empty/unknown still maps to 'de' so the per-shop defaultLanguage chain keeps working. - Tests for pickLanguage and dedupe via node --test + tsx.
14 lines
608 B
SQL
14 lines
608 B
SQL
-- Idempotency table for inbound Shopify webhooks. We insert a row keyed on
|
|
-- the X-Shopify-Webhook-Id header at the start of webhook processing; a
|
|
-- duplicate insert (P2002) means Shopify retried a delivery we've already
|
|
-- seen, so we short-circuit and return 200 without doing the work twice.
|
|
CREATE TABLE "ProcessedWebhook" (
|
|
"webhookId" TEXT NOT NULL PRIMARY KEY,
|
|
"topic" TEXT NOT NULL,
|
|
"shopDomain" TEXT NOT NULL,
|
|
"receivedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE INDEX "ProcessedWebhook_shopDomain_topic_idx"
|
|
ON "ProcessedWebhook"("shopDomain", "topic");
|