<commit_before>import kueLib from 'kue';
import config from './config';
import { renderWelcomeTemplate, renderResetTemplate } from './src/email-templates/index';
import { sendEmail } from './src/utils/email';

let queue = kueLib.createQueue(config.kue);

queue.process('register-user-email', async function(job, done) {
  const { username,
        email,
        hash } = job.data;
  let html = await renderWelcomeTemplate(new Date(), username, email, `http://www.libertysoil.org/api/verify/${hash}`);
  await sendEmail('Welcome to Libertysoil.org', html, job.data.email);
  done();
});

queue.process('reset-password-email', async function(job, done) {
  let html = await renderResetTemplate(new Date(), job.data.username, job.data.email, `http://www.libertysoil.org/newpassword/${job.data.hash}`);
  await sendEmail('Reset Libertysoil.org Password', html, job.data.email);
  done();
});

console.log('Job service started');<commit_msg>Handling job errors with try catch<commit_after>import kueLib from 'kue';
import config from './config';
import { renderWelcomeTemplate, renderResetTemplate } from './src/email-templates/index';
import { sendEmail } from './src/utils/email';

let queue = kueLib.createQueue(config.kue);

queue.process('register-user-email', async function(job, done) {
  const { username,
          email,
          hash } = job.data;

  try {
    let html = await renderWelcomeTemplate(new Date(), username, email, `http://www.libertysoil.org/api/verify/${hash}`);
    await sendEmail('Welcome to Libertysoil.org', html, job.data.email);
    done();
  } catch (e) {
    console.log(`Job error: ${e.message}`);
  }
});

queue.process('reset-password-email', async function(job, done) {
  try {
    let html = await renderResetTemplate(new Date(), job.data.username, job.data.email, `http://www.libertysoil.org/newpassword/${job.data.hash}`);
    await sendEmail('Reset Libertysoil.org Password', html, job.data.email);
    done();
  } catch (e) {
    console.log(`Job error: ${e.message}`);
  }
});

console.log('Job service started');
{'fraction_non_alphanumeric': 0.16536964980544747, 'fraction_numerical': 0.0, 'mean_word_length': 4.3428571428571425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7159030', 'n_tokens_mistral': 648, 'n_tokens_neox': 652, 'n_words': 148}