Public
Like
lightweightQueue
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.
Viewing readonly version of main branch: v22View latest version
Your lightweight queue system is set up and ready to use!
A complete SQLite-based queue system with:
- โ Database schema initialized
- โ Priority-based task processing
- โ Delayed/scheduled execution
- โ Automatic retries with dead letter queue
- โ Worker running every minute
- โ Built-in monitoring
Visit: https://www.val.town/x/nbbaier/lightweightQueue
curl -X POST https://nbbaier--c5bd3e20c8cc11f0a88c42dde27851f2.web.val.run \ -H "Content-Type: application/json" \ -d '{ "task_type": "log_message", "payload": { "message": "Hello from my queue!", "level": "info" } }'
Visit: https://lightweightqueue-monitor.val.run/
| Endpoint | Purpose | URL |
|---|---|---|
| Enqueue | Add tasks to queue | https://lightweightqueue-enqueue.val.run/ |
| Monitor | View queue stats | https://lightweightqueue-monitor.val.run/ |
| Schema | Initialize DB (already done) | https://nbbaier--ba92dd0cc8cc11f0979842dde27851f2.web.val.run |
- log_message - Log a message
- send_email - Send an email via Val Town
- webhook - Call an external webhook
- http_request - Make HTTP requests
{ "task_type": "log_message", "payload": { "message": "Important task!" }, "priority": 10 }
{ "task_type": "log_message", "payload": { "message": "Future task!" }, "scheduled_for": 1732406400 }
{ "task_type": "send_email", "payload": { "to": "user@example.com", "subject": "Test", "text": "Hello from the queue!" } }
Edit processors.ts and add a new processor:
case "my_custom_task":
await processMyCustomTask(payload);
break;
schema.ts- Database initializationenqueue.ts- API to add tasksworker.ts- Processes tasks every minuteprocessors.ts- Task processing logicmonitor.ts- Queue statistics APItest.ts- Example test casesREADME.md- Full documentation
- Run the test file to see it in action
- Check the monitor endpoint to see queue stats
- Add your own custom task processors
- Adjust worker interval if needed (currently 1 minute)
See README.md for complete documentation including:
- All task type examples
- API reference
- Architecture details
- Error handling
- Best practices
Note: The worker processes up to 10 tasks per minute. Failed tasks are automatically retried up to 3 times before moving to the dead letter queue.