diff --git a/.gitignore b/.gitignore index 5148e52..d7eb932 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ jspm_packages # Optional REPL history .node_repl_history +sendgrid.env diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000..95d4013 Binary files /dev/null and b/dump.rdb differ diff --git a/kue-cubit.js b/kue-cubit.js new file mode 100644 index 0000000..1bc886c --- /dev/null +++ b/kue-cubit.js @@ -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() + }) +}) diff --git a/kue-job-list.js b/kue-job-list.js new file mode 100644 index 0000000..96bd0bf --- /dev/null +++ b/kue-job-list.js @@ -0,0 +1,11 @@ +var kue = require('kue') +var queue = kue.createQueue() + +var data = { + from: 'Dokobot ', + to: 'bambang.handoko12@gmail.com', + subject: 'Hello World from the SendGrid Node.js Library! oke oke', + text: 'Testing some Mailgun awesomness.. Ahooyyy!' +} + +var nitip = queue.create('email', data).save() diff --git a/package.json b/package.json new file mode 100644 index 0000000..8af60ea --- /dev/null +++ b/package.json @@ -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" + } +}