Node.js / TypeScript
import { Aside } from ‘@astrojs/starlight/components’;
Quickstart
Historical package install steps below. Prefer check-in recipes for new setups.
1. Prerequisites
- Node.js 18+
- A Crontinel account (sign up free)
- An app created in the dashboard
- Your API key (
crn_live_...) from app settings
2. Install
npm install @crontinel/nodeOr with your preferred package manager:
# yarnyarn add @crontinel/node
# pnpmpnpm add @crontinel/node3. Configure
Create a quickstart.mjs file:
import Crontinel from '@crontinel/node';
const crontinel = new Crontinel({ apiKey: process.env.CRONTINEL_API_KEY, appName: 'my-first-app',});
// Report a cron job runawait crontinel.scheduleRun({ command: 'hello-from-node', duration_ms: 100, exit_code: 0,});
console.log('Data sent to Crontinel!');Set your API key and run it:
export CRONTINEL_API_KEY=crn_live_xxxxxxxxxxxxnode quickstart.mjs4. Dashboard verification
- Go to app.crontinel.com → Apps → your app
- Check the Cron section — you should see the
hello-from-nodejob with exit code0and100msduration - Your first data is on the dashboard!
Requirements
- Node.js 18+
Install
npm install @crontinel/node# oryarn add @crontinel/node# orpnpm add @crontinel/nodeQuick Start
import Crontinel from '@crontinel/node';
const crontinel = new Crontinel({ apiKey: process.env.CRONTINEL_API_KEY!, appName: 'my-service',});
// Report a cron job runawait crontinel.scheduleRun({ command: 'reports:generate', duration_ms: 2340, exit_code: 0, // 0 = success, 1 = failure});
// Report queue worker activityawait crontinel.queueProcessed({ queue: 'emails', processed: 12, failed: 0, duration_ms: 8901,});monitorSchedule helper
Wrap any async function and automatically report its outcome:
const result = await crontinel.monitorSchedule('reports:generate', async () => { const sent = await sendDailyReports(); return { sent, failed: 0 };});// { result: { sent: 142, failed: 0 }, duration_ms: 1840, exit_code: 0 }BullMQ integration
import { Worker } from 'bullmq';import Crontinel from '@crontinel/node';
const crontinel = new Crontinel({ apiKey: process.env.CRONTINEL_API_KEY! });
const worker = new Worker('emails', async (job) => { const start = Date.now(); try { const result = await processJob(job); await crontinel.queueProcessed({ queue: 'emails', processed: 1, failed: 0, duration_ms: Date.now() - start }); return result; } catch (err) { await crontinel.queueProcessed({ queue: 'emails', processed: 0, failed: 1, duration_ms: Date.now() - start }); throw err; }}, { connection: redisConnection });node-cron integration
import cron from 'node-cron';import Crontinel from '@crontinel/node';
const crontinel = new Crontinel({ apiKey: process.env.CRONTINEL_API_KEY! });
cron.schedule('0 9 * * *', async () => { const result = await crontinel.monitorSchedule('send-daily-reports', dailyReportTask); console.log('Report sent:', result.exit_code === 0 ? 'OK' : 'FAILED');});Environment variables
| Variable | Default | Description |
|---|---|---|
CRONTINEL_API_KEY | — | Your Crontinel API key (required) |
CRONTINEL_API_URL | https://app.crontinel.com | SaaS or self-hosted endpoint |