I've not used kue before, so this is going off their documentation:
var kue = require('kue');
var jobs = kue.createQueue();
var create_job = function(data, callback){
var job = jobs.create('job', {
stuff: data
}).save();
job.on('complete', function(){
callback();
}).on('failed', function(){
callback({error: true});
});
};
I've created/used a JavaScript closure to capture the value of the callback
argument (by attaching the events within the scope of the create_job
function, and it's later called when the function completes (or fails).