This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cartReducer = (state = { | |
| cartItems: 0, | |
| items: products, | |
| cartContents: [], | |
| }, action) => { | |
| switch (action.type) { | |
| case "ADD_TO_CART": { | |
| const existingItem = state.cartContents.find(item => { | |
| return item.id === Number(action.payload); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import BonusContext from './bonus-context'; | |
| class App extends Component { | |
| static contextType = BonusContext; | |
| render() { | |
| return( | |
| <li className={ this.context ? 'current' : '' }> | |
| <NavLink | |
| exact |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // some helper fns.. maybe in a different file or not | |
| function validateEmail(email){ | |
| return false; | |
| } | |
| export default (db) => { | |
| // define some route handlers | |
| function onPostCheckMail (req, res) { | |
| if(validateEmail(req.body.email) === true){ //validateEmail is undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| routeConfig.post('/Dashboard/Index', repos.DashboardRepository.getRangeData(repos), (req, res) => { | |
| let queries = [], | |
| sess = req.userSession, | |
| filter = req.rangeFilter; | |
| queries.push(repos.PromotionRepository.getAgencyPromotions(sess.agencyId, 'all')); | |
| queries.push(repos.DashboardRepository.getIndex(repos, filter, sess)); | |
| queries.push(repos.PolicyRepository.getPolicies(filter, true)); | |
| Promise.all(queries) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); | |
| const { promisify } = require('util'); | |
| const writeFileAsync = promisify(fs.writeFile); | |
| const s3etm = require('s3-emails-to-mongo'); | |
| // MAKE THIS PART DYNAMIC LATER | |
| s3etm.configure({ | |
| Bucket: 'zhillb-mail', | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Promise = require('bluebird'); | |
| const bcrypt = require('bcrypt'); | |
| const User = require('../models/user'); | |
| const { LoginError } = require('../errors'); | |
| function checkPassword(password, hash) { | |
| return Promise.try(() => { | |
| return bcrypt.compare(password, hash); | |
| }).then((result) => { | |
| if (!result) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // do this | |
| cache.remember('key1', 600, function() { | |
| return mysql.MobileAction.findOne({ where: {action_id: req.query.D} }) | |
| }).then((val) => { | |
| console.log('set: ', val); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| return Promise.try(() => { | |
| return memcached.getAsync(key); | |
| }).then((value) => { | |
| if (value !== undefined) { | |
| console.log('exists'); | |
| return value; | |
| } else { | |
| return Promise.try(() => { | |
| if (typeof callback === "function") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cache.remember('key', 600, function() { | |
| return Promise.resolve('value2'); | |
| }).then((val) => { | |
| console.log('set: ', val); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| return Promise.try(() => { | |
| return memcached.getAsync(key); | |
| }).then((value) => { | |
| if (value !== undefined) { | |
| return value; | |
| } else { | |
| return Promise.try(() => { | |
| return callback() | |
| }).then((value) => { |
NewerOlder