creatawebhoodforabusiness
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data โ all from the browser, and deployed in miliseconds.
index.ts
https://Victoria1234--ee50f49a3fb911f0867076b3cceeab13.web.val.run
A fully functional webhook system for handling order notifications in your business. This system can receive order events from e-commerce platforms, payment processors, or other systems and send appropriate notifications.
Your webhook system is now live and ready to use!
- Demo Interface: View the live demo interface
- Webhook Endpoint:
https://Victoria1234--ee50f49a3fb911f0867076b3cceeab13.web.val.run/webhook/orders
- Orders API:
https://Victoria1234--ee50f49a3fb911f0867076b3cceeab13.web.val.run/api/orders
- โ Webhook Receiver: Secure endpoint to receive order notifications
- โ Order Processing: Validates and processes order data
- โ Email Notifications: Sends order confirmations to customers and business
- โ Database Storage: Stores order history for tracking
- โ Security: Validates webhook signatures for security
- โ Demo Interface: Interactive testing and monitoring dashboard
- โ REST API: Full CRUD operations for order management
โโโ backend/
โ โโโ database/
โ โ โโโ migrations.ts # Database schema setup
โ โ โโโ queries.ts # Order database operations
โ โโโ routes/
โ โ โโโ webhook.ts # Webhook endpoint handler
โ โ โโโ orders.ts # Order management API
โ โโโ index.ts # Main server entry point
โโโ frontend/
โ โโโ index.html # Demo interface
โโโ shared/
โ โโโ types.ts # Shared TypeScript types
โโโ README.md
-
Environment Variables (optional):
WEBHOOK_SECRET
: Secret key for validating webhook signaturesBUSINESS_EMAIL
: Email address to receive order notifications
-
The webhook endpoint is available at:
/webhook/orders
Send POST requests to the webhook endpoint with order data:
curl -X POST https://your-domain.web.val.run/webhook/orders \ -H "Content-Type: application/json" \ -d '{ "event": "order.created", "data": { "orderId": "ORD-12345", "customerEmail": "customer@example.com", "customerName": "John Doe", "items": [ { "name": "Product Name", "quantity": 2, "price": 29.99 } ], "total": 59.98, "status": "paid", "timestamp": "2024-01-15T10:30:00Z" } }'
- โ Validates the webhook signature (if configured)
- โ Processes the order data
- โ Stores the order in the database
- โ Sends email notifications to customer and business
- โ Returns a success response
GET /api/orders
- Get recent ordersGET /api/orders/:orderId
- Get specific orderGET /api/orders/customer/:email
- Get orders by customerGET /api/status
- System statusGET /webhook/health
- Webhook health check
{ "event": "order.created", "data": { "orderId": "ORD-12345", "customerEmail": "customer@example.com", "customerName": "John Doe", "items": [ { "name": "Product Name", "quantity": 2, "price": 29.99, "sku": "PROD-001" // optional } ], "total": 59.98, "status": "paid", // paid, pending, shipped, delivered, cancelled "timestamp": "2024-01-15T10:30:00Z", "shippingAddress": { // optional "street": "123 Main St", "city": "Anytown", "state": "CA", "zipCode": "12345", "country": "USA" }, "metadata": {} // optional additional data } }
- Optional webhook signature validation using
x-webhook-signature
header - Input validation for all order data
- SQL injection protection through parameterized queries
- CORS enabled for web interface
The system automatically sends:
- Customer confirmation emails with order details
- Business notification emails (if
BUSINESS_EMAIL
is configured)
Your order notification webhook system is fully functional and ready for production use. You can:
- Test it now using the demo interface
- Integrate it with your e-commerce platform
- Monitor orders through the API endpoints
- Customize the email templates and business logic as needed