Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
BaseJob
✓ import { BaseJob } from 'adonis-resque'
✗ const BaseJob = require('adonis-resque').BaseJob
ESM-only package (AdonisJS v6). Named export, not default.
Worker
✓ import { Worker } from 'adonis-resque'
✗ import Worker from 'adonis-resque'
Named export. Default export is not available.
Queue
✓ import { Queue } from 'adonis-resque'
✗ import { ResqueQueue } from 'adonis-resque'
Export name is Queue, not ResqueQueue.
#jobs/*
✓ import Example from '#jobs/example'
✗ import Example from './app/jobs/example'
Requires sub-path import configuration in package.json and tsconfig.json.
Shows installation, creating a job class, enqueuing a background task from a controller, and starting worker/scheduler processes.
// 1. Install and configure
// npm install adonis-resque@2.0.0-alpha.0
// node ace configure adonis-resque
// 2. Create a job file (app/jobs/send_email.ts)
import { BaseJob } from 'adonis-resque'
import logger from '@adonisjs/core/services/logger'
export default class SendEmail extends BaseJob {
static get $$filepath() { return __filename }
async perform(email: string, subject: string) {
// Simulate sending email
logger.info(`Sending email to ${email} with subject: ${subject}`)
// Actual mail sending logic here
}
}
// 3. Enqueue the job from a controller or service
import SendEmail from '#jobs/send_email'
export default class UserController {
async register({ request, response }) {
const { email } = request.all()
// Dispatch background job
await SendEmail.enqueue(email, 'Welcome!')
// Or with delay (5 minutes)
// await SendEmail.enqueue(email, 'Welcome!', { delay: 300 })
return response.ok({ message: 'User registered and email queued' })
}
}
// 4. Start the worker (e.g., in a separate process or via ace command)
// node ace resque:worker
// 5. Start the scheduler for delayed jobs
// node ace resque:scheduler
Errors
Common errors & fixes
Cannot find module '#jobs/example' or its corresponding type declarations.
Missing sub-path import configuration in package.json or tsconfig.json.
fixAdd `"#jobs/*": ["./app/jobs/*.js"]` to `package.json` under `exports` and to `tsconfig.json` under `compilerOptions.paths`.
TypeError: Job.enqueue(...).delay is not a function
Using v2 code with v1 chainable API; delay method was removed.
fixUse `await Job.enqueue(args, { delay: 300 })` instead of chaining. Property 'logger' does not exist on type 'YourJob'.
v2 removed `this.logger` from job instances.
fixImport logger separately: `import logger from '@adonisjs/core/services/logger'`.
Audit
Dependencies
@adonisjs/corerequiredPeer dependency required by AdonisJS application ecosystem
@adonisjs/redisrequiredRequired for Redis connection used by node-resque
node-resquerequiredCore library providing the Resque queue implementation