This file contains 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
var promisify = require("es6-promisify"); // you can also look for a promisifyAll equivalent, but for the sake of demonstration | |
function findText(freeText, result) { | |
var query = { | |
index: result.teamUnique + "_team", | |
type: result.username, | |
body: { | |
query: { | |
match: { | |
name: freeText |
This file contains 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
criterion.forEach(function(item) { | |
item.maprange = item.startmap + " "; | |
if (item.endmap != null && item.startmap !== item.endmap) { | |
item.maprange += " - " + item.endmap; | |
} | |
}) |
This file contains 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
var Promise = require("bluebird"); | |
function promisifyWaterline(action){ | |
return Promise.try(function() { | |
return action(); | |
}).catch(function(err) { | |
// you should almost never catch errors inline. ONLY do it if you need to 'repackage' an error. | |
// definitely don't do the below, as you lose the original error. | |
throw new Error("lol"); | |
}) |
This file contains 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
return new Promise((resolve, reject) => { | |
var currentDate = moment().format(); | |
var dates = []; | |
for (var i = 1; i < days + 1; i++) { | |
dates.push(moment().subtract(i, "days")); | |
} | |
resolve(dates); |
This file contains 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
passport.use(new LocalStrategy( | |
function(username, password, done) { | |
collections.UserCollection.forge() | |
.query(function (qb) { | |
qb.where('username', '=', username.toLowerCase()); | |
}) | |
.fetchOne() | |
.then(function (user) { | |
if (user == null) { |
This file contains 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
var Promise = require("bluebird"); | |
var bhttp = Promise.promisifyAll(require("bhttp")); | |
// config encapsulates opensensors-api-key | |
// the only key config should have is "api-key" | |
module.exports = function(config) { | |
var API_BASE_URL = "https://api.opensensors.io/v1/"; | |
var API_OPTIONS = { | |
headers: { | |
Accept: "application/json", |
This file contains 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
'use strict'; | |
var _ = require('lodash'); | |
var async = require('async'); | |
var moment = require('moment'); | |
var Promise = require('bluebird'); | |
var messaging = require('../../messaging'); | |
var patients = require('../patients'); | |
var practitioners = require('../practitioners'); | |
var dataProvider = require('../../database'); |
This file contains 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
var aws = require('aws-sdk'), | |
Promise = require('bluebird'), | |
chalk = require('chalk'), | |
messageFactory = require('./factory'), | |
config = require('./config.json'); | |
var sqs = new Promise.promisifyAll(new aws.SQS({ | |
region: config.aws.region, | |
accessKeyId: config.aws.accessId, |
This file contains 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
AuctionController.getAll = function() { | |
return collections.AuctionCollection.forge().fetch(); | |
}; |
This file contains 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
return Promise.try(function () { | |
return MongoClient.connectAsync(MONGODB_CONNECTION_STRING) | |
}).then(function(db){ | |
return Promise.try(function(){ | |
return db.collection("downloads").findOneAsync({key: status.filename}); | |
}).then(function(item){ | |
return Promise.try(function() { | |
return db.closeAsync(); | |
}).then(function() { | |
return item; |