Skip to content

Commit 58ff3c3

Browse files
committed
setup and use kue and redis
1 parent 59af10c commit 58ff3c3

File tree

3,435 files changed

+458897
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,435 files changed

+458897
-2
lines changed

config/kue.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const kue=require('kue');
2+
3+
const queue=kue.createQueue();
4+
5+
module.exports=queue;

controllers/comments_controller.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const Comment = require('../models/comment');
22
const Post = require('../models/posts');
33
const commentsMailer=require('../mailers/comments_mailer');
4+
const kue=require('../config/kue');
5+
const commentsEmailworker=require('../workers/comment_email');
6+
const queue = require('../config/kue');
7+
48

59
module.exports.create = async function(req, res){
610

@@ -17,7 +21,16 @@ module.exports.create = async function(req, res){
1721
post.comments.push(comment);
1822
post.save();
1923
comment = await comment.populate('user', 'name email').execPopulate();
20-
commentsMailer.newComment(comment);
24+
// commentsMailer.newComment(comment);
25+
let job = queue.create('emails',comment).save(function(err){
26+
27+
if(err){
28+
console.log('error in creating a queue');
29+
return;
30+
}
31+
32+
console.log('job enqueued',job.id);
33+
});
2134

2235
if (req.xhr){
2336
// Similar for comments to fetch the user's id!

mailers/comments_mailer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exports.newComment=(comment)=>{
2424
console.log('error in sending mail',err);
2525
return;
2626
}
27-
console.log('Message Sent',info);
27+
// console.log('Message Sent',info);
2828
return;
2929

3030
})

node_modules/.bin/acorn

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/atob

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/babylon

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/kue-dashboard

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/stylus

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uglifyjs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@types/babel-types/LICENSE

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@types/babel-types/README.md

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)