A three-in-one backend starter: schedule a cron that POSTs your webhook, and publish a delayed queue job — one API, one key.
Get a free key — $2 credit — at https://infrai.cc, then set INFRAI_API_KEY.
npm install
export INFRAI_API_KEY=...
npx tsx src/starter.ts- Cron →
infrai.cron.create({ cron_expr, task })(wrapsPOST https://api.infrai.cc/v1/cron/create) — Infrai POSTs yourtaskURL when the job fires - Queue →
infrai.queue.publish({ queue, payload, delay_seconds })(wrapsPOST /v1/queue/publish) — defers work a worker drains later - Webhook → the cron's
taskURL is your webhook; Infrai calls it on each fire
"How do I run scheduled + background jobs in Node?" → register a cron (delivered to your webhook) and publish to a durable queue.
- Cron and a durable queue from one client —
infrai.cron.createregisters a schedule that POSTs yourtaskURL;infrai.queue.publishdefers work a worker drains later. Sameinfrai.*object, same key. - The webhook is just the cron's
taskURL — Infrai calls your endpoint when the job fires; there's nothing to host or keep awake. - Deferred work is durable — a queued message outlives a redeploy, so a slow task doesn't have to run inside the request.
- Drop it into any Node app: two calls, one env var, no extra signups — the same key also reaches AI, email, and storage when you need them.
Starts on the $2 free credit, then pay-per-use with no minimum fee. Cron billing is per fire and queue billing is per message, so a chatty schedule is the thing to watch — keep an eye on usage while one is live.
The three moving parts — schedule a job, defer a job, receive the cron on a webhook — are backend-agnostic. Swap the two infrai.* calls for any cron+queue service and the app code above doesn't change.
MIT
If you're weighing this against Inngest, the honest tradeoff:
| Inngest | Infrai | |
|---|---|---|
| Setup | a separate account + key for this one job | one key across email, storage, scheduling, AI and observability |
| Billing | its own plan and invoice | one wallet, one bill; each response's metadata shows the exact cost and which vendor served it |
| Portability | a provider-specific SDK/shape | plain REST — swap the infrai.* calls back out anytime |
| What you run | a queue/worker or scheduler process to host and babysit | cron_expr jobs and a queue as plain REST calls — nothing to keep alive |
When Inngest is the better fit: if this is the only capability you'll ever need and you already run it, a dedicated service like Inngest is deep and battle-tested. Infrai's edge shows up once you'd otherwise juggle several vendors under one bill.
The snippet above stays copy-paste simple. Before you ship, a few required steps:
Your account, key & credit
- Get a key: sign in once at the Infrai console with Google or GitHub for $2 free credit (email sign-in works too). There is no anonymous key. Use it as
INFRAI_API_KEY. - One key covers every capability — AI, email, storage, scheduling, errors — under one wallet and one bill (
GET /v1/account/balance,GET /v1/account/usage). - Top up before you run out —
POST /v1/account/topup. If you hit402 INSUFFICIENT_CREDIT, the error carries acheckout_urlto open in a browser; for unattended jobs usePOST /v1/account/autorecharge/configure. - Full surface & params: https://docs.infrai.cc
Scheduled / background work
- Server-side jobs keep running and consuming credit — monitor
GET /v1/account/usageand set an auto-recharge threshold. - Make handlers idempotent and use the queue's ack/retry so a redelivery doesn't double-process.