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
client.select('*').from(opts.table).stream() | |
.pipe(through.obj(function chunkToFiles (chunk, enc, callback) { | |
const primaryKey = chunk[opts.primaryKey] | |
Object.keys(chunk).forEach((key) => { | |
this.push(new File({ | |
path: `./${primaryKey}/${key}`, | |
contents: new Buffer(chunk[key] + '') | |
})) | |
}) |
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
static login(email, password) { | |
return Promise.try(() => { | |
return Account.fetch(email)) | |
}).then((acc) => { | |
return Promise.try(() => { | |
bcrypt.compareAsync(password, acc.password) | |
}).then(result => { | |
if (result) { | |
console.log(`User logged in: ${acc.email}`); | |
const token = jwt.sign(_.pick(acc, ['id', 'email', 'agencyId']), |
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
ended: false, | |
endEmitted: false, | |
reading: true, | |
sync: false, | |
needReadable: true, | |
emittedReadable: false, | |
readableListening: false, | |
defaultEncoding: 'utf8', | |
ranOut: false, | |
awaitDrain: 0, |
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; |
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
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
'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 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
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
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); |