New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

task-kue

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

task-kue

Task based Queue that runs on Kue

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
5
400%
Maintainers
1
Weekly downloads
 
Created
Source

Task-Kue

Task-Kue is a task queue for Node.JS that builds on the Kue priority job queue library and Redis. Task-Kue automatically serializes Task objects and queues them up for a worker process to deserialize and run.

Create a Task queue (my-task-queue.js)

const TaskKue = require('task-kue');
const myTaskQueue = new TaskKue();
module.exports = myTaskQueue;

Define a Task Object

And register it with the task queue you defined.

const myTaskQueue = require('my-task-queue');
const Task = require('task-kue').Task;

class EmailTask extends Task {
    constructor(email, subject, body) {
        this.email = email;
        this.subject = subject;
        this.body = body;
    }

    run() {
        return smtpPromise(this.email,this.subject, this.body);
    }
}

myTaskQueue.register(EmailTask);

Create a Worker and run it

const myTaskQueue = require('my-task-queue');

var worker = myTaskQueue.buildWorker();

worker.onError(function(e, job) {
	util.log(e.stack);
});

worker.process();

Execute a task asyncronously

new EmailTask("hello@world.com", "Test Email", "Test Body").queue().save();

All of the kue methods (delay, priority) are available before saving the Task.

FAQs

Package last updated on 13 Feb 2017

Did you know?

Socket

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.

Install

Related posts