Examples
Minimal, self-contained example apps live in the
examples/ folder of the repository.
Most examples use the PGLite driver with a file-backed data directory under the repo-root
tmp/ folder, so nothing external needs to be installed or started — no Docker, no database
server. The two PostgreSQL examples connect to a real PostgreSQL server instead (they need the pg
peer dependency and a DATABASE_URL). Each folder is a workspace package that resolves
@portqueue/* straight from the repo.
| Example | Driver | What it shows |
|---|---|---|
dashboard-node-server | PGLite | Serve the dashboard from a plain node:http server |
dashboard-express | PGLite | Mount the dashboard as Express middleware alongside your own routes |
job-scheduling | PGLite | Delayed (one-off) and recurring (interval + cron) jobs — see Delayed & recurring jobs |
retries-backoff | PGLite | Retries with fixed/exponential backoff and jitter — see Retries & backoff |
idempotency-singleton | PGLite | idempotencyKey and singletonKey deduplication — see Producing jobs |
graceful-shutdown | PGLite | Draining in-flight handlers via job.signal on shutdown |
postgresql-connection | PostgreSQL | Connect to a real PostgreSQL server with DATABASE_URL |
transactional-enqueue | PostgreSQL | Enqueue a job atomically with your own DB write — see Transactions |
Running
From the repo root. Every launcher rebuilds @portqueue/core and @portqueue/dashboard first, so
an example always runs the code in your working tree rather than a stale dist/ — set
PORTQUEUE_SKIP_BUILD=1 to skip that when you haven't touched any package source. Each
example has a root npm run example:* script; if you prefer, there's an equivalent shell script
under scripts/dev/examples/
that does the same thing (some devs like running the .sh versions directly):
npm run example:dashboard-node # http://127.0.0.1:4321/portqueue
./scripts/dev/examples/dashboard-node-server.sh
npm run example:dashboard-express # http://127.0.0.1:4322/portqueue
./scripts/dev/examples/dashboard-express.sh
npm run example:schedule-delayed
./scripts/dev/examples/job-scheduling-delayed.sh
npm run example:schedule-recurring
./scripts/dev/examples/job-scheduling-recurring.sh
npm run example:retries
npm run example:idempotency
npm run example:graceful
The two PostgreSQL examples need a reachable database that already exists — set DATABASE_URL first:
DATABASE_URL=postgres://user:pass@localhost:5432/app npm run example:postgresql
DATABASE_URL=postgres://user:pass@localhost:5432/app npm run example:transactional
Or run an example directly from its folder with npm start (dashboards, retries, idempotency,
graceful, and the PostgreSQL examples) / npm run delayed / npm run recurring (job-scheduling).