@boostkit/queue-inngest
v0.0.5
Published
Inngest serverless queue adapter for `@boostkit/queue`.
Readme
@boostkit/queue-inngest
Inngest serverless queue adapter for @boostkit/queue.
Installation
pnpm add @boostkit/queue-inngest inngestUsage
1. Configure the queue
// config/queue.ts
import { Env } from '@boostkit/core/support'
import { SendWelcomeEmailJob } from '../app/Jobs/SendWelcomeEmailJob.js'
export default {
default: 'inngest',
connections: {
inngest: {
driver: 'inngest',
appId: Env.get('INNGEST_APP_ID', 'my-boostkit-app'),
signingKey: Env.get('INNGEST_SIGNING_KEY'),
eventKey: Env.get('INNGEST_EVENT_KEY'),
baseUrl: Env.get('APP_URL', 'http://localhost:3000'),
jobs: [
SendWelcomeEmailJob,
],
},
},
}2. Register the provider
// bootstrap/providers.ts
import { queue } from '@boostkit/queue'
import configs from '../config/index.js'
export default [
queue(configs.queue),
]3. Mount the Inngest endpoint
Inngest requires an HTTP endpoint to receive function registration and event delivery. Mount it in your routes:
// routes/api.ts
import { router } from '@boostkit/router'
import { inngest } from '@boostkit/queue-inngest'
import configs from '../config/index.js'
// Mount the Inngest serve handler at /api/inngest
router.all('/api/inngest', inngest(configs.queue.connections.inngest).serveHandler())4. Define jobs
// app/Jobs/SendWelcomeEmailJob.ts
import { Job } from '@boostkit/queue'
export class SendWelcomeEmailJob extends Job {
static retries = 3 // Optional: override default retry count
constructor(private readonly data: { email: string; name: string }) {
super()
}
async handle(): Promise<void> {
await sendEmail({
to: this.data.email,
subject: 'Welcome!',
body: `Hello, ${this.data.name}!`,
})
}
}5. Dispatch jobs
import { SendWelcomeEmailJob } from '../app/Jobs/SendWelcomeEmailJob.js'
await SendWelcomeEmailJob.dispatch({
data: { email: '[email protected]', name: 'Alice' }
}).send()API Reference
InngestConfiginngest(config)→QueueAdapterProviderinngest(config).serveHandler()→ route handler forrouter.all('/api/inngest', ...)
Configuration
InngestConfigdriver—'inngest'appId— unique app identifier shown in the Inngest dashboardsigningKey?— Inngest signing key (required in production)eventKey?— Inngest event key (required in production)baseUrl?— app's public URL (Inngest uses this to call your serve endpoint)jobs— array of job classes to register with Inngest
Event Naming
BoostKit maps job class names to Inngest event names using the pattern:
boostkit/job.<ClassName>For example, SendWelcomeEmailJob is dispatched as the boostkit/job.SendWelcomeEmailJob event.
Retries
Override the default retry count on a job class:
export class SendWelcomeEmailJob extends Job {
static retries = 5 // retry up to 5 times on failure
// ...
}Development Setup
In development, run the Inngest Dev Server locally:
npx inngest-cli@latest devThe dev server runs at http://localhost:8288 and automatically discovers your functions by calling the /api/inngest endpoint. No signing key is needed in development.
Set APP_URL so Inngest can reach your endpoint:
APP_URL=http://localhost:3000
INNGEST_APP_ID=my-boostkit-appProduction Setup
In production (Inngest Cloud):
INNGEST_APP_ID=my-boostkit-app
INNGEST_SIGNING_KEY=signkey-prod-...
INNGEST_EVENT_KEY=eventkey-...
APP_URL=https://my-app.example.comInngest will call your /api/inngest endpoint to register functions and deliver events.
Notes
- All job classes must be listed in the
jobsarray for Inngest to register them - The
/api/inngestroute must be publicly reachable for Inngest to deliver events - Inngest handles retries, concurrency, and observability automatically via the dashboard
serveHandler()returns aMiddlewareHandlercompatible withrouter.all()
