Public
Like
saintforgeAI
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
index.ts
https://saint--c1d99c363fa611f08b3076b3cceeab13.web.val.run
A comprehensive email notification system with API endpoints for integration, supporting reminders, alerts, newsletters, and transactional emails.
- Multiple Notification Types: Reminders, alerts, newsletters, transactional emails
- Dynamic Recipients: Rule-based recipient selection
- Webhook Integration: Receive and process webhooks to trigger notifications
- Form Submission Handling: Process form data and send notifications
- Template System: Customizable email templates
- Recipient Management: Store and manage recipient lists with criteria
- API-First Design: RESTful endpoints for all operations
POST /api/recipients
- Add new recipientGET /api/recipients
- List all recipientsPUT /api/recipients/:id
- Update recipientDELETE /api/recipients/:id
- Remove recipient
POST /api/templates
- Create email templateGET /api/templates
- List all templatesPUT /api/templates/:id
- Update templateDELETE /api/templates/:id
- Delete template
POST /api/notifications/send
- Send immediate notificationPOST /api/webhooks/notification
- Webhook endpoint for triggering notificationsPOST /api/forms/submit
- Form submission endpoint
GET /api/notifications/history
- Get notification historyGET /api/notifications/stats
- Get sending statistics
βββ backend/
β βββ database/
β β βββ migrations.ts # Database schema setup
β β βββ queries.ts # Database query functions
β βββ routes/
β β βββ recipients.ts # Recipient management
β β βββ templates.ts # Template management
β β βββ notifications.ts # Notification sending
β β βββ webhooks.ts # Webhook handling
β β βββ forms.ts # Form submission handling
β βββ services/
β β βββ emailService.ts # Email sending logic
β β βββ recipientService.ts # Recipient filtering
β β βββ templateService.ts # Template processing
β βββ index.ts # Main API server
βββ shared/
β βββ types.ts # Shared TypeScript types
βββ README.md
curl -X POST /api/recipients \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", "name": "John Doe", "tags": ["premium", "newsletter"], "preferences": { "notifications": true, "newsletters": true } }'
curl -X POST /api/templates \ -H "Content-Type: application/json" \ -d '{ "name": "welcome_email", "type": "transactional", "subject": "Welcome {{name}}!", "html": "<h1>Welcome {{name}}</h1><p>Thanks for joining!</p>", "text": "Welcome {{name}}! Thanks for joining!" }'
curl -X POST /api/notifications/send \ -H "Content-Type: application/json" \ -d '{ "type": "alert", "template": "system_alert", "criteria": { "tags": ["admin"], "preferences.notifications": true }, "data": { "message": "System maintenance scheduled", "time": "2024-01-15T10:00:00Z" } }'
No API keys required - uses Val Town's built-in email service.