<commit_before>
/*
 * Routes for rendering home index page
 */

var Fashion    = require('../models/fashion.js');
var Category   = require('../models/category.js');
var nodemailer = require('nodemailer');
//var smtpTransport = require('nodemailer-smtp-transport');
var env = process.env.NODE_ENV || 'development'; 
var secrets = require('../config/setting.js');

var transporter = nodemailer.createTransport(({
  service : "Gmail",
  auth : {
    user : secrets.getEmail(env),
    pass : secrets.getPassword(env)
  }
}));

module.exports = {
  index : function(req, res){
    Fashion.find({'trending':'true'}, function(err, fashion){
      if(err) res.send(err);

      res.render('pages/index',{
          fashion : fashion
      });
    });
  },

  contact : function(req, res){
      res.render('pages/contact')
  },

  mailer : function(req, res, next){
    req.checkBody('firstname','Please fill in your names for processing').notEmpty();
    req.checkBody('surname','Please fill in your names for processing').notEmpty();
    req.checkBody('email','Email is required for sending of mail').notEmpty();
    req.checkBody('phone','Phone number is required').notEmpty();
    req.checkBody('message','Cant leave the message field empty').notEmpty();

    var errors = req.validationErrors();
    if(errors){
     res.render('pages/contact',{
        errors:errors,
      });
    }

    var mailOptions = {
      /*to : '<EMAIL>',*/
      to : '<EMAIL>',
      subject : req.body.firstname +' '+req.body.surname,
      text : 'message from contact form of website viewer with email:'+req.body.email+', phone number'+req.body.phone+' and message: ' + req.body.message +'\n\n'
    };
    transporter.sendMail(mailOptions, function(err,info){
      if(err) return next(err);
      return res.send("mail sent successfully");
    });
  },

  categories : function(req, res){
    Category.findOne({name:req.params.category}, function(err, foundCategory){
      if(err) res.send(err);
      if(foundCategory){
          console.log(foundCategory);
          Fashion.find({category:foundCategory._id}, function(err, fashion){<commit_msg>change email to send contacts to<commit_after>
/*
 * Routes for rendering home index page
 */

var Fashion    = require('../models/fashion.js');
var Category   = require('../models/category.js');
var nodemailer = require('nodemailer');
//var smtpTransport = require('nodemailer-smtp-transport');
var env = process.env.NODE_ENV || 'development'; 
var secrets = require('../config/setting.js');

var transporter = nodemailer.createTransport(({
  service : "Gmail",
  auth : {
    user : secrets.getEmail(env),
    pass : <PASSWORD>(env)
  }
}));

module.exports = {
  index : function(req, res){
    Fashion.find({'trending':'true'}, function(err, fashion){
      if(err) res.send(err);

      res.render('pages/index',{
          fashion : fashion
      });
    });
  },

  contact : function(req, res){
      res.render('pages/contact')
  },

  mailer : function(req, res, next){
    req.checkBody('firstname','Please fill in your names for processing').notEmpty();
    req.checkBody('surname','Please fill in your names for processing').notEmpty();
    req.checkBody('email','Email is required for sending of mail').notEmpty();
    req.checkBody('phone','Phone number is required').notEmpty();
    req.checkBody('message','Cant leave the message field empty').notEmpty();

    var errors = req.validationErrors();
    if(errors){
     res.render('pages/contact',{
        errors:errors,
      });
    }

    var mailOptions = {
      to : '<EMAIL>',
      subject : req.body.firstname +' '+req.body.surname,
      text : 'message from contact form of website viewer with email:'+req.body.email+', phone number'+req.body.phone+' and message: ' + req.body.message +'\n\n'
    };
    transporter.sendMail(mailOptions, function(err,info){
      if(err) return next(err);
      return res.send("mail sent successfully");
    });
  },

  categories : function(req, res){
    Category.findOne({name:req.params.category}, function(err, foundCategory){
      if(err) res.send(err);
      if(foundCategory){
          console.log(foundCategory);
          Fashion.find({category:foundCategory._id}, function(err, fashion){
{'fraction_non_alphanumeric': 0.16478076379066478, 'fraction_numerical': 0.0, 'mean_word_length': 3.466315789473684, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1594829', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1263, 'n_words': 282}