Create a Next.js API route that receives inventory update webhooks from partner organizations. Requirements: 1. POST /api/webhooks/inventory accepts JSON payloads with: org_id, items (array of {name, category, quantity, unit, expiration_date}), timestamp 2. Validate payload with zod.reject malformed requests with 400 3. Verify webhook signature using HMAC-SHA256 (secret per org) 4. Upsert inventory records in the database 5. Trigger matching algorithm for new surplus items 6. Return 200 with processed item count Include rate limiting (max 60 requests/minute per org). Write integration tests.
No contributions yet.