• Blog
  • Docs
  • Pricing
  • Weโ€™re hiring!
Log inSign up
nbbaier

nbbaier

lightweightQueue

SQLite-based queue system for Val Town
Public
Like
lightweightQueue
Home
Code
8
QUICKSTART.md
README.md
H
enqueue.ts
H
monitor.ts
processors.ts
H
schema.ts
test.ts
C
worker.ts
Branches
1
Pull requests
Remixes
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: v19
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.