• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
nbbaier

nbbaier

lightweightQueue

SQLite-based queue system for Val Town
Public
Like
lightweightQueue
Home
Code
11
.vtignore
AGENTS.md
QUICKSTART.md
README.md
deno.json
H
enqueue.ts
H
monitor.ts
processors.ts
H
schema.ts
test.ts
C
worker.ts
Branches
1
Pull requests
Remixes
1
History
Environment variables
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.
Sign up now
Code
/
QUICKSTART.md
Code
/
QUICKSTART.md
Search
…
Viewing readonly version of main branch: v24
View latest version
QUICKSTART.md

Quick Start Guide

Your lightweight queue system is set up and ready to use!

🎯 What's Been Created

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

🚀 Quick Start

1. View Your Val

Visit: https://www.val.town/x/nbbaier/lightweightQueue

2. Enqueue Your First Task

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" } }'

3. Monitor Queue Status

Visit: https://lightweightqueue-monitor.val.run/

📊 Key Endpoints

EndpointPurposeURL
EnqueueAdd tasks to queuehttps://lightweightqueue-enqueue.val.run/
MonitorView queue statshttps://lightweightqueue-monitor.val.run/
SchemaInitialize DB (already done)https://nbbaier--ba92dd0cc8cc11f0979842dde27851f2.web.val.run

🎮 Built-in Task Types

  1. log_message - Log a message
  2. send_email - Send an email via Val Town
  3. webhook - Call an external webhook
  4. http_request - Make HTTP requests

💡 Examples

High Priority Task

{ "task_type": "log_message", "payload": { "message": "Important task!" }, "priority": 10 }

Scheduled Task (1 hour from now)

{ "task_type": "log_message", "payload": { "message": "Future task!" }, "scheduled_for": 1732406400 }

Send Email Task

{ "task_type": "send_email", "payload": { "to": "user@example.com", "subject": "Test", "text": "Hello from the queue!" } }

🔧 Customization

Add Your Own Task Types

Edit processors.ts and add a new processor:

case "my_custom_task": await processMyCustomTask(payload); break;

📁 File Structure

  • schema.ts - Database initialization
  • enqueue.ts - API to add tasks
  • worker.ts - Processes tasks every minute
  • processors.ts - Task processing logic
  • monitor.ts - Queue statistics API
  • test.ts - Example test cases
  • README.md - Full documentation

🔍 Next Steps

  1. Run the test file to see it in action
  2. Check the monitor endpoint to see queue stats
  3. Add your own custom task processors
  4. Adjust worker interval if needed (currently 1 minute)

📖 Full Documentation

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.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.