Demonstrates a simple job queue backed by a Redis list. Jobs are pushed to the head and processed from the tail, giving FIFO (first-in, first-out) ordering.
Source: ../src/queue.js
The list queue:emails acts as a queue:
LPUSHadds new jobs to the left (head) of the list.RPOPremoves jobs from the right (tail) of the list.
Combining left-push with right-pop yields FIFO processing order.
Enqueue an email job.
- Body:
{
"to": "user@example.com",
"subject": "Hello",
"body": "Welcome to the app!"
}- Response:
{
"status": "queued",
"job": {
"to": "user@example.com",
"subject": "Hello",
"body": "Welcome to the app!",
"createdAt": "2026-07-28T00:00:00.000Z"
}
}subject defaults to "No Subject" and body defaults to "No content" when omitted.
Dequeue and process the next job (FIFO).
- Response (job available):
{
"status": "Email sent Successfully",
"job": {
"to": "user@example.com",
"subject": "Hello",
"body": "Welcome to the app!",
"createdAt": "2026-07-28T00:00:00.000Z"
}
}- Response (queue empty):
{
"message": "No jobs in the queue"
}Queue an email job:
curl -X POST http://localhost:3000/emails-queue \
-H "Content-Type: application/json" \
-d '{"to":"user@example.com","subject":"Hello","body":"Welcome!"}'Process the next job:
curl http://localhost:3000/emails-queue/process-oneLPUSH- add a job to the head of the listRPOP- remove a job from the tail of the list