DataQueueDataQueue

init

Scaffold a Next.js project for DataQueue with a single command.

Scaffolds your Next.js project with everything needed to start using DataQueue — API routes, a job queue singleton, a cron script, and all required dependencies.

npx dataqueue-cli init

What It Does

The init command auto-detects your project structure (App Router vs Pages Router, src/ directory vs root) and creates the following:

Files Created

FilePurpose
app/api/dataqueue/manage/[[...task]]/route.tsAPI route for queue management (App Router)
pages/api/dataqueue/manage/[[...task]].tsAPI route for queue management (Pages Router)
lib/dataqueue/queue.tsJob queue singleton with a sample send_email handler
cron.shShell script for local development cron jobs

Only the API route matching your detected router is created. Existing files are never overwritten.

Dependencies Added

Production:

  • @nicnocquee/dataqueue
  • @nicnocquee/dataqueue-dashboard
  • @nicnocquee/dataqueue-react

Development:

  • dotenv-cli
  • ts-node
  • node-pg-migrate

Scripts Added

ScriptCommand
cronbash cron.sh
migrate-dataqueuedotenv -e .env.local -- dataqueue-cli migrate

After Running

  1. Install the newly added dependencies:
npm install
  1. Set up your environment variables in .env.local:
PG_DATAQUEUE_DATABASE=postgresql://user:password@localhost:5432/mydb
CRON_SECRET=your-secret-here
  1. Run database migrations:
npm run migrate-dataqueue
  1. Start your Next.js dev server and the cron script:
npm run dev
npm run cron

Requirements

  • Must be run in a Next.js project directory (looks for next in package.json dependencies)
  • Must have either an app/ or pages/ directory