Skip to content

Commit

Permalink
done - bambang handoko
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhandoko committed Mar 15, 2017
1 parent 4521fa5 commit 637dba8
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ jspm_packages

# Optional REPL history
.node_repl_history
sendgrid.env
Binary file added dump.rdb
Binary file not shown.
29 changes: 29 additions & 0 deletions kue-cubit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var kue = require('kue')
var queue = kue.createQueue()
require('dotenv').config()

queue.process('email', function (job, done) {
var helper = require('sendgrid').mail
console.log(job.data)
var from_email = new helper.Email(job.data.from)
var to_email = new helper.Email(job.data.to)
var subject = job.data.subject
var content = new helper.Content('text/plain', job.data.text)
var mail = new helper.Mail(from_email, subject, to_email, content)

console.log(process.env.SENDGRID_API_KEY)
var sg = require('sendgrid')('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'
)
var request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: mail.toJSON()
})

sg.API(request, function (error, response) {
console.log(response.statusCode)
console.log(response.body)
console.log(response.headers)
done()
})
})
11 changes: 11 additions & 0 deletions kue-job-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var kue = require('kue')
var queue = kue.createQueue()

var data = {
from: 'Dokobot <[email protected]>',
to: '[email protected]',
subject: 'Hello World from the SendGrid Node.js Library! oke oke',
text: 'Testing some Mailgun awesomness.. Ahooyyy!'
}

var nitip = queue.create('email', data).save()
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "its-background-job",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/darwins-fox-2017/its-background-job.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/darwins-fox-2017/its-background-job/issues"
},
"homepage": "https://github.com/darwins-fox-2017/its-background-job#readme",
"dependencies": {
"dotenv": "^4.0.0",
"sendgrid": "^4.8.2"
}
}

0 comments on commit 637dba8

Please sign in to comment.