
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@anephenix/job-queue
Advanced tools
A Node.js Job Queue library using Redis.
npm i @anephenix/job-queue
You will need a create a Redis client (v4 of Redis)
// Dependencies
const redisLib = require('redis');
const redisConfig = {};
const redis = redisLib.createClient(redisConfig);
Once you have that, you can create a queue like this:
const { Queue } = require('@anephenix/job-queue');
const emailQueue = new Queue({ queueKey: 'email', redis, hooks: {} });
Once you have the queue ready, you can add jobs like this:
const job = {
name: 'job-001',
data: {
from: 'bob@bob.com',
to: 'sally@sally.com',
subject: 'Have you got the document for ML results?',
body: 'I want to check what the loss rate was. Thanks.',
},
};
emailQueue.add(job);
Workers can be setup like this:
const { Worker } = require('@anephenix/job-queue');
const sendEmail = require('./sendEmail');
class EmailWorker extends Worker {
async processJob(job) {
this.status = 'processing';
try {
await sendEmail(job);
await this.completeJob(job);
} catch (err) {
await this.failJob(job);
}
return;
}
}
const emailWorker = new EmailWorker(emailQueue);
Workers are the base class on which to create Workers tailored to processing the job. In the example above, we have an EmailWorker whose processJob function is customised to send an email via the 'sendEmail' function. The worker is now setup to start processing jobs.
await emailWorker.start();
The worker will now poll the queue for available jobs. Once it has one, it will take the job and process it.
await emailWorker.stop();
Hooks are a way to trigger functions before and after these actions are called on the queue:
This gives you the ability to do things like collect data on how many jobs are being added to a queue, how quickly they are being processed, and so on.
There are 2 types of hook, pre and post. A pre hook is called before the action is triggered, and a post hook is called after.
The way to setup hooks to call can be demonstrated in the example below:
const queueKey = 'email';
const queue = new Queue({
queueKey,
redis,
hooks: {
add: {
pre: async (job) => {
// Do something with the job before it is added
return job;
},
post: async (job) => {
// Do something with the job after it is added
return job;
},
},
take: {},
complete: {},
fail: {},
},
});
©2025 Anephenix OÜ. Job Queue is licensed under the MIT license.
FAQs
Job Queue
The npm package @anephenix/job-queue receives a total of 12 weekly downloads. As such, @anephenix/job-queue popularity was classified as not popular.
We found that @anephenix/job-queue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.