mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
Node 8 (WIP) (#9946)
* start upgrade to node 8 * upgrade travis * improve travis * Remove bluebird, babel (except for modules) from server (WIP) (#9947) * remove bluebird, babel from server (except for modules) * fixes * fix path * fix path * fix export * fix export * fix test * fix tests * remove plugin for transform-object-rest-spread since it is supported in node8 * babel: correct syntax rest spread * remove bluebird * update migrations archive readme * fix package-lock.json * fix typo * add package-loc
This commit is contained in:
8
.babelrc
8
.babelrc
@@ -1,10 +1,6 @@
|
||||
{
|
||||
"presets": ["es2015"],
|
||||
"plugins": [
|
||||
"transform-object-rest-spread",
|
||||
["transform-async-to-module-method", {
|
||||
"module": "bluebird",
|
||||
"method": "coroutine"
|
||||
}]
|
||||
"transform-es2015-modules-commonjs",
|
||||
"syntax-object-rest-spread",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ node_modules/**
|
||||
.bower-registry/**
|
||||
website/client-old/**
|
||||
website/client/**
|
||||
website/client/store/**
|
||||
website/views/**
|
||||
website/build/**
|
||||
dist/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '6'
|
||||
- '8'
|
||||
services:
|
||||
- mongodb
|
||||
cache:
|
||||
@@ -8,8 +8,6 @@ cache:
|
||||
- 'node_modules'
|
||||
addons:
|
||||
chrome: stable
|
||||
before_install:
|
||||
- npm install -g npm@5
|
||||
before_script:
|
||||
- npm run test:build
|
||||
- cp config.json.example config.json
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:boron
|
||||
FROM node:8
|
||||
|
||||
# Upgrade NPM to v5 (Yarn is needed because of this bug https://github.com/npm/npm/issues/16807)
|
||||
# The used solution is suggested here https://github.com/npm/npm/issues/16807#issuecomment-313591975
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:boron
|
||||
FROM node:8
|
||||
|
||||
ENV ADMIN_EMAIL admin@habitica.com
|
||||
ENV AMAZON_PAYMENTS_CLIENT_ID amzn1.application-oa2-client.68ed9e6904ef438fbc1bf86bf494056e
|
||||
|
||||
@@ -2,7 +2,6 @@ import { exec } from 'child_process';
|
||||
import psTree from 'ps-tree';
|
||||
import nconf from 'nconf';
|
||||
import net from 'net';
|
||||
import Bluebird from 'bluebird';
|
||||
import { post } from 'superagent';
|
||||
import { sync as glob } from 'glob';
|
||||
import Mocha from 'mocha';
|
||||
@@ -45,7 +44,7 @@ export function kill (proc) {
|
||||
* before failing.
|
||||
*/
|
||||
export function awaitPort (port, max = 60) {
|
||||
return new Bluebird((rej, res) => {
|
||||
return new Promise((rej, res) => {
|
||||
let socket;
|
||||
let timeout;
|
||||
let interval;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
const authorName = 'Blade';
|
||||
const authorUuid = '75f270e8-c5db-4722-a5e6-a83f1b23f76b';
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const TaskQueue = require('cwait').TaskQueue;
|
||||
const logger = require('./utils/logger');
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
* pm'ed each user asking if they would like their tasks reset to the previous day
|
||||
***************************************/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const TaskQueue = require('cwait').TaskQueue;
|
||||
const logger = require('./utils/logger');
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* from an object to a number, hence this migration.
|
||||
***************************************/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
const TaskQueue = require('cwait').TaskQueue;
|
||||
const logger = require('./utils/logger');
|
||||
const Timer = require('./utils/timer');
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
* and transfers a group's progress to it
|
||||
***************************************/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
const TaskQueue = require('cwait').TaskQueue;
|
||||
const logger = require('./utils/logger');
|
||||
const Timer = require('./utils/timer');
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* <userid>@example.com
|
||||
***************************************/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
const TaskQueue = require('cwait').TaskQueue;
|
||||
const logger = require('./utils/logger');
|
||||
const Timer = require('./utils/timer');
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
* they support a type and options and label
|
||||
* ***************************************/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
const TaskQueue = require('cwait').TaskQueue;
|
||||
const logger = require('./utils/logger');
|
||||
const Timer = require('./utils/timer');
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* message into the chat for affected parties.
|
||||
***************************************/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
const uuid = require('uuid');
|
||||
const TaskQueue = require('cwait').TaskQueue;
|
||||
const logger = require('./utils/logger');
|
||||
|
||||
@@ -2,3 +2,5 @@ If you need to use a migration from this folder, move it to /migrations.
|
||||
|
||||
Note that /migrations files (excluding /archive) are linted, so to pass test you'll have to make sure
|
||||
that the file is written correctly.
|
||||
|
||||
They might also be using some old deps that we don't use anymore like Bluebird, mongoskin, ...
|
||||
@@ -1,5 +1,3 @@
|
||||
import Bluebird from 'Bluebird';
|
||||
|
||||
import { model as Challenges } from '../../website/server/models/challenge';
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
@@ -17,10 +15,10 @@ async function syncChallengeToMembers (challenges) {
|
||||
promises.push(user.save());
|
||||
});
|
||||
|
||||
return Bluebird.all(promises);
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
return await Bluebird.all(challengSyncPromises);
|
||||
return await Promise.all(challengSyncPromises);
|
||||
}
|
||||
|
||||
async function syncChallenges (lastChallengeDate) {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
import { model as Group } from '../../website/server/models/group';
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
@@ -16,7 +14,7 @@ async function createGroup (name, privacy, type, leaderId) {
|
||||
group.leader = user._id;
|
||||
user.guilds.push(group._id);
|
||||
|
||||
return Bluebird.all([group.save(), user.save()]);
|
||||
return Promise.all([group.save(), user.save()]);
|
||||
}
|
||||
|
||||
module.exports = async function groupCreator () {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
/*
|
||||
* This migration will find users with unlimited subscriptions who are also eligible for Jackalope mounts, and award them
|
||||
*/
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
import { model as Group } from '../../website/server/models/group';
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
@@ -38,7 +37,7 @@ async function handOutJackalopes () {
|
||||
|
||||
cursor.on('close', async () => {
|
||||
console.log('done');
|
||||
return await Bluebird.all(promises);
|
||||
return await Promise.all(promises);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ let authorUuid = ''; // ... own data is done
|
||||
* subscription to all members
|
||||
*/
|
||||
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
import { model as Group } from '../../website/server/models/group';
|
||||
import * as payments from '../../website/server/libs/payments';
|
||||
|
||||
@@ -28,7 +26,7 @@ async function updateGroupsWithGroupPlans () {
|
||||
});
|
||||
|
||||
cursor.on('close', async () => {
|
||||
return await Bluebird.all(promises);
|
||||
return await Promise.all(promises);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
require('babel-register');
|
||||
require('babel-polyfill');
|
||||
|
||||
// This file must use ES5, everything required can be in ES6
|
||||
|
||||
function setUpServer () {
|
||||
const nconf = require('nconf'); // eslint-disable-line global-require, no-unused-vars
|
||||
const mongoose = require('mongoose'); // eslint-disable-line global-require, no-unused-vars
|
||||
const Bluebird = require('bluebird'); // eslint-disable-line global-require, no-unused-vars
|
||||
const setupNconf = require('../website/server/libs/setupNconf'); // eslint-disable-line global-require
|
||||
|
||||
setupNconf();
|
||||
|
||||
// We require src/server and npt src/index because
|
||||
// 1. nconf is already setup
|
||||
// 2. we don't need clustering
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
let Bluebird = require('bluebird');
|
||||
let request = require('superagent');
|
||||
let last = require('lodash/last');
|
||||
let AWS = require('aws-sdk');
|
||||
@@ -74,7 +73,7 @@ function uploadToS3 (start, end, filesUrls) {
|
||||
});
|
||||
console.log(promises.length);
|
||||
|
||||
return Bluebird.all(promises)
|
||||
return Promise.all(promises)
|
||||
.then(() => {
|
||||
currentIndex += 50;
|
||||
uploadToS3(currentIndex, currentIndex + 50, filesUrls);
|
||||
|
||||
1910
package-lock.json
generated
1910
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@
|
||||
"babel-loader": "^7.1.4",
|
||||
"babel-plugin-syntax-async-functions": "^6.13.0",
|
||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
||||
"babel-plugin-transform-async-to-module-method": "^6.8.0",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.16.0",
|
||||
"babel-plugin-transform-regenerator": "^6.16.1",
|
||||
"babel-polyfill": "^6.6.1",
|
||||
@@ -26,7 +26,6 @@
|
||||
"babel-register": "^6.6.0",
|
||||
"babel-runtime": "^6.11.6",
|
||||
"bcrypt": "^1.0.2",
|
||||
"bluebird": "^3.3.5",
|
||||
"body-parser": "^1.15.0",
|
||||
"bootstrap": "^4.0.0",
|
||||
"bootstrap-vue": "^2.0.0-rc.2",
|
||||
@@ -113,8 +112,8 @@
|
||||
},
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": "^6.9.1",
|
||||
"npm": "^5.0.0"
|
||||
"node": "^8.9.4",
|
||||
"npm": "^5.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --ext .js,.vue .",
|
||||
@@ -141,6 +140,7 @@
|
||||
"apidoc": "gulp apidoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
|
||||
"babel-plugin-istanbul": "^4.1.6",
|
||||
"chai": "^4.1.2",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
require('babel-register');
|
||||
require('babel-polyfill');
|
||||
|
||||
// This file is used for creating paypal billing plans. PayPal doesn't have a web interface for setting up recurring
|
||||
// payment plan definitions, instead you have to create it via their REST SDK and keep it updated the same way. So this
|
||||
|
||||
@@ -2,9 +2,9 @@ import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-v3-integration.helper';
|
||||
import xml2js from 'xml2js';
|
||||
import Bluebird from 'bluebird';
|
||||
import util from 'util';
|
||||
|
||||
let parseStringAsync = Bluebird.promisify(xml2js.parseString, {context: xml2js});
|
||||
let parseStringAsync = util.promisify(xml2js.parseString).bind(xml2js);
|
||||
|
||||
describe('GET /export/userdata.xml', () => {
|
||||
// TODO disabled because it randomly causes the build to fail
|
||||
|
||||
@@ -2,8 +2,8 @@ import {
|
||||
createAndPopulateGroup,
|
||||
translate as t,
|
||||
generateUser,
|
||||
sleep,
|
||||
} from '../../../../helpers/api-v3-integration.helper';
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
describe('POST /groups/:groupId/quests/accept', () => {
|
||||
const PET_QUEST = 'whale';
|
||||
@@ -140,7 +140,7 @@ describe('POST /groups/:groupId/quests/accept', () => {
|
||||
// quest will start after everyone has accepted
|
||||
await partyMembers[1].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await Bluebird.delay(500);
|
||||
await sleep(0.5);
|
||||
|
||||
await rejectingMember.sync();
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import {
|
||||
createAndPopulateGroup,
|
||||
translate as t,
|
||||
generateUser,
|
||||
sleep,
|
||||
} from '../../../../helpers/api-v3-integration.helper';
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
const PET_QUEST = 'whale';
|
||||
@@ -135,7 +135,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
|
||||
|
||||
await Bluebird.delay(500);
|
||||
await sleep(0.5);
|
||||
|
||||
await Promise.all([
|
||||
partyMemberThatRejects.sync(),
|
||||
@@ -161,7 +161,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
|
||||
|
||||
await Bluebird.delay(500);
|
||||
await sleep(0.5);
|
||||
|
||||
await questingGroup.sync();
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
|
||||
|
||||
await Bluebird.delay(500);
|
||||
await sleep(0.5);
|
||||
|
||||
await questingGroup.sync();
|
||||
|
||||
@@ -201,7 +201,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
|
||||
|
||||
await Bluebird.delay(500);
|
||||
await sleep(0.5);
|
||||
|
||||
await questingGroup.sync();
|
||||
|
||||
@@ -222,7 +222,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
|
||||
|
||||
await Bluebird.delay(500);
|
||||
await sleep(0.5);
|
||||
|
||||
await questingGroup.sync();
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import {
|
||||
createAndPopulateGroup,
|
||||
translate as t,
|
||||
generateUser,
|
||||
sleep,
|
||||
} from '../../../../helpers/api-v3-integration.helper';
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
describe('POST /groups/:groupId/quests/reject', () => {
|
||||
let questingGroup;
|
||||
@@ -168,7 +168,7 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
||||
// quest will start after everyone has accepted or rejected
|
||||
await rejectingMember.post(`/groups/${questingGroup._id}/quests/reject`);
|
||||
|
||||
await Bluebird.delay(500);
|
||||
await sleep(0.5);
|
||||
|
||||
await questingGroup.sync();
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
describe('GET /shops/market', () => {
|
||||
let user;
|
||||
@@ -42,13 +41,13 @@ describe('GET /shops/market', () => {
|
||||
return array;
|
||||
}, []);
|
||||
|
||||
let results = await Bluebird.each(items, (item) => {
|
||||
let results = await Promise.all(items.map((item) => {
|
||||
let { purchaseType, key } = item;
|
||||
return user.post(`/user/purchase/${purchaseType}/${key}`);
|
||||
});
|
||||
}));
|
||||
|
||||
expect(results.length).to.be.greaterThan(0);
|
||||
results.forEach((item) => {
|
||||
items.forEach((item) => {
|
||||
expect(item).to.include.keys('key', 'text', 'notes', 'class', 'value', 'currency');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,8 +2,8 @@ import {
|
||||
generateUser,
|
||||
generateGroup,
|
||||
generateChallenge,
|
||||
sleep,
|
||||
} from '../../../../../helpers/api-integration/v3';
|
||||
import Bluebird from 'bluebird';
|
||||
import { find } from 'lodash';
|
||||
|
||||
describe('POST /tasks/:id/score/:direction', () => {
|
||||
@@ -27,7 +27,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
text: 'test habit',
|
||||
type: 'habit',
|
||||
});
|
||||
await Bluebird.delay(1000);
|
||||
await sleep(1);
|
||||
let updatedUser = await user.get('/user');
|
||||
usersChallengeTaskId = updatedUser.tasksOrder.habits[0];
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
text: 'test daily',
|
||||
type: 'daily',
|
||||
});
|
||||
await Bluebird.delay(1000);
|
||||
await sleep(1);
|
||||
let updatedUser = await user.get('/user');
|
||||
usersChallengeTaskId = updatedUser.tasksOrder.dailys[0];
|
||||
});
|
||||
@@ -109,7 +109,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
text: 'test todo',
|
||||
type: 'todo',
|
||||
});
|
||||
await Bluebird.delay(1000);
|
||||
await sleep(1);
|
||||
let updatedUser = await user.get('/user');
|
||||
usersChallengeTaskId = updatedUser.tasksOrder.todos[0];
|
||||
});
|
||||
@@ -134,7 +134,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
text: 'test reward',
|
||||
type: 'reward',
|
||||
});
|
||||
await Bluebird.delay(1000);
|
||||
await sleep(1);
|
||||
let updatedUser = await user.get('/user');
|
||||
usersChallengeTaskId = updatedUser.tasksOrder.todos[0];
|
||||
});
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
each,
|
||||
map,
|
||||
} from 'lodash';
|
||||
import Bluebird from 'bluebird';
|
||||
import {
|
||||
sha1MakeSalt,
|
||||
sha1Encrypt as sha1EncryptPassword,
|
||||
@@ -104,7 +103,7 @@ describe('DELETE /user', () => {
|
||||
password,
|
||||
});
|
||||
|
||||
await Bluebird.all(map(ids, id => {
|
||||
await Promise.all(map(ids, id => {
|
||||
return expect(checkExistence('tasks', id)).to.eventually.eql(false);
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* eslint-disable global-require */
|
||||
import moment from 'moment';
|
||||
import nconf from 'nconf';
|
||||
import Bluebird from 'bluebird';
|
||||
import requireAgain from 'require-again';
|
||||
import { recoverCron, cron } from '../../../../../website/server/libs/cron';
|
||||
import { model as User } from '../../../../../website/server/models/user';
|
||||
@@ -1363,7 +1362,7 @@ describe('recoverCron', () => {
|
||||
});
|
||||
|
||||
it('throws an error if user cannot be found', async () => {
|
||||
execStub.returns(Bluebird.resolve(null));
|
||||
execStub.returns(Promise.resolve(null));
|
||||
|
||||
try {
|
||||
await recoverCron(status, locals);
|
||||
@@ -1374,8 +1373,8 @@ describe('recoverCron', () => {
|
||||
});
|
||||
|
||||
it('increases status.times count and reruns up to 4 times', async () => {
|
||||
execStub.returns(Bluebird.resolve({_cronSignature: 'RUNNING_CRON'}));
|
||||
execStub.onCall(4).returns(Bluebird.resolve({_cronSignature: 'NOT_RUNNING'}));
|
||||
execStub.returns(Promise.resolve({_cronSignature: 'RUNNING_CRON'}));
|
||||
execStub.onCall(4).returns(Promise.resolve({_cronSignature: 'NOT_RUNNING'}));
|
||||
|
||||
await recoverCron(status, locals);
|
||||
|
||||
@@ -1384,7 +1383,7 @@ describe('recoverCron', () => {
|
||||
});
|
||||
|
||||
it('throws an error if recoverCron runs 5 times', async () => {
|
||||
execStub.returns(Bluebird.resolve({_cronSignature: 'RUNNING_CRON'}));
|
||||
execStub.returns(Promise.resolve({_cronSignature: 'RUNNING_CRON'}));
|
||||
|
||||
try {
|
||||
await recoverCron(status, locals);
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
attachTranslateFunction,
|
||||
} from '../../../../../website/server/middlewares/language';
|
||||
import common from '../../../../../website/common';
|
||||
import Bluebird from 'bluebird';
|
||||
import { model as User } from '../../../../../website/server/models/user';
|
||||
|
||||
const i18n = common.i18n;
|
||||
@@ -162,7 +161,7 @@ describe('language middleware', () => {
|
||||
return this;
|
||||
},
|
||||
exec () {
|
||||
return Bluebird.resolve({
|
||||
return Promise.resolve({
|
||||
preferences: {
|
||||
language: 'it',
|
||||
},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import Bluebird from 'bluebird';
|
||||
import moment from 'moment';
|
||||
import { model as User } from '../../../../../website/server/models/user';
|
||||
import { model as Group } from '../../../../../website/server/models/group';
|
||||
@@ -123,7 +122,7 @@ describe('User Model', () => {
|
||||
it('adds notifications without data for all given users via static method', async () => {
|
||||
let user = new User();
|
||||
let otherUser = new User();
|
||||
await Bluebird.all([user.save(), otherUser.save()]);
|
||||
await Promise.all([user.save(), otherUser.save()]);
|
||||
|
||||
await User.pushNotification({_id: {$in: [user._id, otherUser._id]}}, 'CRON');
|
||||
|
||||
@@ -149,7 +148,7 @@ describe('User Model', () => {
|
||||
it('adds notifications with data and seen status for all given users via static method', async () => {
|
||||
let user = new User();
|
||||
let otherUser = new User();
|
||||
await Bluebird.all([user.save(), otherUser.save()]);
|
||||
await Promise.all([user.save(), otherUser.save()]);
|
||||
|
||||
await User.pushNotification({_id: {$in: [user._id, otherUser._id]}}, 'CRON', {field: 1}, true);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
times,
|
||||
} from 'lodash';
|
||||
import Bluebird from 'bluebird';
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
import { ApiUser, ApiGroup, ApiChallenge } from '../api-classes';
|
||||
import { requester } from '../requester';
|
||||
@@ -106,7 +105,7 @@ export async function createAndPopulateGroup (settings = {}) {
|
||||
guild: { guilds: [group._id] },
|
||||
};
|
||||
|
||||
let members = await Bluebird.all(
|
||||
let members = await Promise.all(
|
||||
times(numberOfMembers, () => {
|
||||
return generateUser(groupMembershipTypes[group.type]);
|
||||
})
|
||||
@@ -114,7 +113,7 @@ export async function createAndPopulateGroup (settings = {}) {
|
||||
|
||||
await group.update({ memberCount: numberOfMembers + 1});
|
||||
|
||||
let invitees = await Bluebird.all(
|
||||
let invitees = await Promise.all(
|
||||
times(numberOfInvites, () => {
|
||||
return generateUser();
|
||||
})
|
||||
@@ -126,9 +125,9 @@ export async function createAndPopulateGroup (settings = {}) {
|
||||
});
|
||||
});
|
||||
|
||||
await Bluebird.all(invitationPromises);
|
||||
await Promise.all(invitationPromises);
|
||||
|
||||
await Bluebird.map(invitees, (invitee) => invitee.sync());
|
||||
await Promise.all(invitees.map((invitee) => invitee.sync()));
|
||||
|
||||
return {
|
||||
groupLeader,
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
/* eslint-disable global-require */
|
||||
/* eslint-disable no-process-env */
|
||||
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
//------------------------------
|
||||
// Global modules
|
||||
//------------------------------
|
||||
@@ -16,7 +14,6 @@ global.sinon = require('sinon');
|
||||
let sinonStubPromise = require('sinon-stub-promise');
|
||||
sinonStubPromise(global.sinon);
|
||||
global.sandbox = sinon.sandbox.create();
|
||||
global.Promise = Bluebird;
|
||||
|
||||
import setupNconf from '../../website/server/libs/setupNconf';
|
||||
setupNconf('./config.json.example');
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
export async function sleep (seconds = 1) {
|
||||
let milliseconds = seconds * 1000;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, milliseconds);
|
||||
});
|
||||
}
|
||||
export { default as sleep } from '../../website/server/libs/sleep';
|
||||
@@ -1,13 +1,11 @@
|
||||
/* eslint-disable no-process-env */
|
||||
import nconf from 'nconf';
|
||||
import mongoose from 'mongoose';
|
||||
import Bluebird from 'bluebird';
|
||||
import setupNconf from '../../website/server/libs/setupNconf';
|
||||
|
||||
if (process.env.LOAD_SERVER === '0') { // when the server is in a different process we simply connect to mongoose
|
||||
setupNconf('./config.json');
|
||||
// Use Q promises instead of mpromise in mongoose
|
||||
mongoose.Promise = Bluebird;
|
||||
mongoose.connect(nconf.get('TEST_DB_URI'));
|
||||
} else { // When running tests and the server in the same process
|
||||
setupNconf('./config.json.example');
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
--timeout 8000
|
||||
--check-leaks
|
||||
--globals io
|
||||
-r babel-polyfill
|
||||
--require babel-register
|
||||
--require ./test/helpers/globals.helper
|
||||
--exit
|
||||
|
||||
@@ -11,12 +11,12 @@ source /home/vagrant/.profile
|
||||
|
||||
echo Setting up node...
|
||||
cd /vagrant
|
||||
nvm install
|
||||
nvm use
|
||||
nvm install 8
|
||||
nvm use 8
|
||||
nvm alias default current
|
||||
|
||||
echo Update npm...
|
||||
npm install -g npm@4
|
||||
npm install -g npm@5
|
||||
|
||||
echo Installing global modules...
|
||||
npm install -g gulp mocha node-pre-gyp
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
NotAuthorized,
|
||||
} from '../../libs/errors';
|
||||
import * as Tasks from '../../models/task';
|
||||
import Bluebird from 'bluebird';
|
||||
import csvStringify from '../../libs/csvStringify';
|
||||
import {
|
||||
createTasks,
|
||||
@@ -254,7 +253,7 @@ api.joinChallenge = {
|
||||
addUserJoinChallengeNotification(user);
|
||||
|
||||
// Add all challenge's tasks to user's tasks and save the challenge
|
||||
let results = await Bluebird.all([challenge.syncToUser(user), challenge.save()]);
|
||||
let results = await Promise.all([challenge.syncToUser(user), challenge.save()]);
|
||||
|
||||
let response = results[1].toJSON();
|
||||
response.group = getChallengeGroupResponse(group);
|
||||
@@ -306,7 +305,7 @@ api.leaveChallenge = {
|
||||
if (!challenge.isMember(user)) throw new NotAuthorized(res.t('challengeMemberNotFound'));
|
||||
|
||||
// Unlink challenge's tasks from user's tasks and save the challenge
|
||||
await Bluebird.all([challenge.unlinkTasks(user, keep), challenge.save()]);
|
||||
await Promise.all([challenge.unlinkTasks(user, keep), challenge.save()]);
|
||||
|
||||
res.analytics.track('challenge leave', {
|
||||
uuid: user._id,
|
||||
@@ -364,8 +363,8 @@ api.getUserChallenges = {
|
||||
|
||||
let resChals = challenges.map(challenge => challenge.toJSON());
|
||||
// Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833
|
||||
await Bluebird.all(resChals.map((chal, index) => {
|
||||
return Bluebird.all([
|
||||
await Promise.all(resChals.map((chal, index) => {
|
||||
return Promise.all([
|
||||
User.findById(chal.leader).select(nameFields).exec(),
|
||||
Group.findById(chal.group).select(basicGroupFields).exec(),
|
||||
]).then(populatedData => {
|
||||
@@ -419,7 +418,7 @@ api.getGroupChallenges = {
|
||||
|
||||
let resChals = challenges.map(challenge => challenge.toJSON());
|
||||
// Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833
|
||||
await Bluebird.all(resChals.map((chal, index) => {
|
||||
await Promise.all(resChals.map((chal, index) => {
|
||||
return User
|
||||
.findById(chal.leader)
|
||||
.select(nameFields)
|
||||
@@ -511,7 +510,7 @@ api.exportChallengeCsv = {
|
||||
// In v2 this used the aggregation framework to run some computation on MongoDB but then iterated through all
|
||||
// results on the server so the perf difference isn't that big (hopefully)
|
||||
|
||||
let [members, tasks] = await Bluebird.all([
|
||||
let [members, tasks] = await Promise.all([
|
||||
User.find({challenges: challengeId})
|
||||
.select(nameFields)
|
||||
.sort({_id: 1})
|
||||
|
||||
@@ -14,7 +14,6 @@ import pusher from '../../libs/pusher';
|
||||
import { getAuthorEmailFromMessage } from '../../libs/chat';
|
||||
import { chatReporterFactory } from '../../libs/chatReporting/chatReporterFactory';
|
||||
import nconf from 'nconf';
|
||||
import Bluebird from 'bluebird';
|
||||
import bannedWords from '../../libs/bannedWords';
|
||||
import guildsAllowingBannedWords from '../../libs/guildsAllowingBannedWords';
|
||||
import { getMatchesByWordArray } from '../../libs/stringUtils';
|
||||
@@ -184,7 +183,7 @@ api.postChat = {
|
||||
toSave.push(user.save());
|
||||
}
|
||||
|
||||
let [savedGroup] = await Bluebird.all(toSave);
|
||||
let [savedGroup] = await Promise.all(toSave);
|
||||
|
||||
// realtime chat is only enabled for private groups (for now only for parties)
|
||||
if (savedGroup.privacy === 'private' && savedGroup.type === 'party') {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import common from '../../../common';
|
||||
import _ from 'lodash';
|
||||
import { langCodes } from '../../libs/i18n';
|
||||
import Bluebird from 'bluebird';
|
||||
import fsCallback from 'fs';
|
||||
import path from 'path';
|
||||
import logger from '../../libs/logger';
|
||||
import util from 'util';
|
||||
|
||||
// Transform fs methods that accept callbacks in ones that return promises
|
||||
const fs = {
|
||||
readFile: Bluebird.promisify(fsCallback.readFile, {context: fsCallback}),
|
||||
writeFile: Bluebird.promisify(fsCallback.writeFile, {context: fsCallback}),
|
||||
stat: Bluebird.promisify(fsCallback.stat, {context: fsCallback}),
|
||||
mkdir: Bluebird.promisify(fsCallback.mkdir, {context: fsCallback}),
|
||||
readFile: util.promisify(fsCallback.readFile).bind(fsCallback),
|
||||
writeFile: util.promisify(fsCallback.writeFile).bind(fsCallback),
|
||||
stat: util.promisify(fsCallback.stat).bind(fsCallback),
|
||||
mkdir: util.promisify(fsCallback.mkdir).bind(fsCallback),
|
||||
};
|
||||
|
||||
let api = {};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import Bluebird from 'bluebird';
|
||||
import _ from 'lodash';
|
||||
import nconf from 'nconf';
|
||||
import {
|
||||
@@ -137,7 +136,7 @@ api.createGroup = {
|
||||
user.party._id = group._id;
|
||||
}
|
||||
|
||||
let results = await Bluebird.all([user.save(), group.save()]);
|
||||
let results = await Promise.all([user.save(), group.save()]);
|
||||
let savedGroup = results[1];
|
||||
|
||||
// Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833
|
||||
@@ -194,7 +193,7 @@ api.createGroupPlan = {
|
||||
group.leader = user._id;
|
||||
user.guilds.push(group._id);
|
||||
|
||||
let results = await Bluebird.all([user.save(), group.save()]);
|
||||
let results = await Promise.all([user.save(), group.save()]);
|
||||
let savedGroup = results[1];
|
||||
|
||||
// Analytics
|
||||
@@ -617,7 +616,7 @@ api.joinGroup = {
|
||||
}
|
||||
}
|
||||
|
||||
promises = await Bluebird.all(promises);
|
||||
promises = await Promise.all(promises);
|
||||
|
||||
let response = Group.toJSONCleanChat(promises[0], user);
|
||||
let leader = await User.findById(response.leader).select(nameFields).exec();
|
||||
@@ -915,7 +914,7 @@ api.removeGroupMember = {
|
||||
let message = req.query.message || req.body.message;
|
||||
_sendMessageToRemoved(group, member, message, isInGroup);
|
||||
|
||||
await Bluebird.all([
|
||||
await Promise.all([
|
||||
member.save(),
|
||||
group.save(),
|
||||
]);
|
||||
@@ -1167,7 +1166,7 @@ api.inviteToGroup = {
|
||||
|
||||
if (uuids) {
|
||||
let uuidInvites = uuids.map((uuid) => _inviteByUUID(uuid, group, user, req, res));
|
||||
let uuidResults = await Bluebird.all(uuidInvites);
|
||||
let uuidResults = await Promise.all(uuidInvites);
|
||||
results.push(...uuidResults);
|
||||
}
|
||||
|
||||
@@ -1175,7 +1174,7 @@ api.inviteToGroup = {
|
||||
let emailInvites = emails.map((invite) => _inviteByEmail(invite, group, user, req, res));
|
||||
user.invitesSent += emails.length;
|
||||
await user.save();
|
||||
let emailResults = await Bluebird.all(emailInvites);
|
||||
let emailResults = await Promise.all(emailInvites);
|
||||
results.push(...emailResults);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
getUserInfo,
|
||||
sendTxn as sendTxnEmail,
|
||||
} from '../../libs/email';
|
||||
import Bluebird from 'bluebird';
|
||||
import { sendNotification as sendPushNotification } from '../../libs/pushNotifications';
|
||||
import { achievements } from '../../../../website/common/';
|
||||
|
||||
@@ -552,7 +551,7 @@ api.transferGems = {
|
||||
receiver.balance += amount;
|
||||
sender.balance -= amount;
|
||||
let promises = [receiver.save(), sender.save()];
|
||||
await Bluebird.all(promises);
|
||||
await Promise.all(promises);
|
||||
|
||||
// generate the message in both languages, so both users can understand it
|
||||
let receiverLang = receiver.preferences.language;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import Bluebird from 'bluebird';
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import analytics from '../../libs/analyticsService';
|
||||
import {
|
||||
@@ -109,7 +108,7 @@ api.inviteToQuest = {
|
||||
await group.startQuest(user);
|
||||
}
|
||||
|
||||
let [savedGroup] = await Bluebird.all([
|
||||
let [savedGroup] = await Promise.all([
|
||||
group.save(),
|
||||
user.save(),
|
||||
]);
|
||||
@@ -312,7 +311,7 @@ api.forceStart = {
|
||||
|
||||
await group.startQuest(user);
|
||||
|
||||
let [savedGroup] = await Bluebird.all([
|
||||
let [savedGroup] = await Promise.all([
|
||||
group.save(),
|
||||
user.save(),
|
||||
]);
|
||||
@@ -372,7 +371,7 @@ api.cancelQuest = {
|
||||
group.quest = Group.cleanGroupQuest();
|
||||
group.markModified('quest');
|
||||
|
||||
let [savedGroup] = await Bluebird.all([
|
||||
let [savedGroup] = await Promise.all([
|
||||
group.save(),
|
||||
User.update(
|
||||
{'party._id': groupId},
|
||||
@@ -441,7 +440,7 @@ api.abortQuest = {
|
||||
group.quest = Group.cleanGroupQuest();
|
||||
group.markModified('quest');
|
||||
|
||||
let [groupSaved] = await Bluebird.all([group.save(), memberUpdates, questLeaderUpdate]);
|
||||
let [groupSaved] = await Promise.all([group.save(), memberUpdates, questLeaderUpdate]);
|
||||
|
||||
res.respond(200, groupSaved.quest);
|
||||
},
|
||||
@@ -486,7 +485,7 @@ api.leaveQuest = {
|
||||
user.party.quest = Group.cleanQuestProgress();
|
||||
user.markModified('party.quest');
|
||||
|
||||
let [savedGroup] = await Bluebird.all([
|
||||
let [savedGroup] = await Promise.all([
|
||||
group.save(),
|
||||
user.save(),
|
||||
]);
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
setNextDue,
|
||||
} from '../../libs/taskManager';
|
||||
import common from '../../../common';
|
||||
import Bluebird from 'bluebird';
|
||||
import _ from 'lodash';
|
||||
import logger from '../../libs/logger';
|
||||
import moment from 'moment';
|
||||
@@ -598,7 +597,7 @@ api.scoreTask = {
|
||||
});
|
||||
|
||||
managerPromises.push(task.save());
|
||||
await Bluebird.all(managerPromises);
|
||||
await Promise.all(managerPromises);
|
||||
|
||||
throw new NotAuthorized(res.t('taskApprovalHasBeenRequested'));
|
||||
}
|
||||
@@ -647,7 +646,7 @@ api.scoreTask = {
|
||||
task.save(),
|
||||
];
|
||||
if (taskOrderPromise) promises.push(taskOrderPromise);
|
||||
let results = await Bluebird.all(promises);
|
||||
let results = await Promise.all(promises);
|
||||
|
||||
let savedUser = results[0];
|
||||
|
||||
@@ -1132,7 +1131,7 @@ api.unlinkAllTasks = {
|
||||
if (!validTasks) throw new BadRequest(res.t('cantOnlyUnlinkChalTask'));
|
||||
|
||||
if (keep === 'keep-all') {
|
||||
await Bluebird.all(tasks.map(task => {
|
||||
await Promise.all(tasks.map(task => {
|
||||
task.challenge = {};
|
||||
return task.save();
|
||||
}));
|
||||
@@ -1149,7 +1148,7 @@ api.unlinkAllTasks = {
|
||||
|
||||
toSave.push(user.save());
|
||||
|
||||
await Bluebird.all(toSave);
|
||||
await Promise.all(toSave);
|
||||
}
|
||||
|
||||
res.respond(200, {});
|
||||
@@ -1199,7 +1198,7 @@ api.unlinkOneTask = {
|
||||
} else { // remove
|
||||
if (task.type !== 'todo' || !task.completed) { // eslint-disable-line no-lonely-if
|
||||
removeFromArray(user.tasksOrder[`${task.type}s`], taskId);
|
||||
await Bluebird.all([user.save(), task.remove()]);
|
||||
await Promise.all([user.save(), task.remove()]);
|
||||
} else {
|
||||
await task.remove();
|
||||
}
|
||||
@@ -1317,7 +1316,7 @@ api.deleteTask = {
|
||||
// See https://github.com/HabitRPG/habitica/pull/9321#issuecomment-354187666 for more info
|
||||
if (!challenge) user._v++;
|
||||
|
||||
await Bluebird.all([taskOrderUpdate, task.remove()]);
|
||||
await Promise.all([taskOrderUpdate, task.remove()]);
|
||||
} else {
|
||||
await task.remove();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { authWithHeaders } from '../../../middlewares/auth';
|
||||
import Bluebird from 'bluebird';
|
||||
import * as Tasks from '../../../models/task';
|
||||
import { model as Group } from '../../../models/group';
|
||||
import { model as User } from '../../../models/user';
|
||||
@@ -205,7 +204,7 @@ api.assignTask = {
|
||||
let promises = [];
|
||||
promises.push(group.syncTask(task, assignedUser));
|
||||
promises.push(group.save());
|
||||
await Bluebird.all(promises);
|
||||
await Promise.all(promises);
|
||||
|
||||
res.respond(200, task);
|
||||
},
|
||||
@@ -350,7 +349,7 @@ api.approveTask = {
|
||||
|
||||
managerPromises.push(task.save());
|
||||
managerPromises.push(assignedUser.save());
|
||||
await Bluebird.all(managerPromises);
|
||||
await Promise.all(managerPromises);
|
||||
|
||||
res.respond(200, task);
|
||||
},
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
model as Group,
|
||||
} from '../../models/group';
|
||||
import * as Tasks from '../../models/task';
|
||||
import Bluebird from 'bluebird';
|
||||
import _ from 'lodash';
|
||||
import * as passwordUtils from '../../libs/password';
|
||||
import {
|
||||
@@ -415,7 +414,7 @@ api.deleteUser = {
|
||||
return group.leave(user, 'remove-all');
|
||||
});
|
||||
|
||||
await Bluebird.all(groupLeavePromises);
|
||||
await Promise.all(groupLeavePromises);
|
||||
|
||||
await Tasks.Task.remove({
|
||||
userId: user._id,
|
||||
@@ -1470,7 +1469,7 @@ api.userRebirth = {
|
||||
|
||||
toSave.push(user.save());
|
||||
|
||||
await Bluebird.all(toSave);
|
||||
await Promise.all(toSave);
|
||||
|
||||
res.respond(200, ...rebirthRes);
|
||||
},
|
||||
@@ -1627,7 +1626,7 @@ api.userReroll = {
|
||||
let promises = tasks.map(task => task.save());
|
||||
promises.push(user.save());
|
||||
|
||||
await Bluebird.all(promises);
|
||||
await Promise.all(promises);
|
||||
|
||||
res.respond(200, ...rerollRes);
|
||||
},
|
||||
@@ -1668,7 +1667,7 @@ api.userReset = {
|
||||
|
||||
let resetRes = common.ops.reset(user, tasks);
|
||||
|
||||
await Bluebird.all([
|
||||
await Promise.all([
|
||||
Tasks.Task.remove({_id: {$in: resetRes[0].tasksToRemove}, userId: user._id}),
|
||||
user.save(),
|
||||
]);
|
||||
|
||||
@@ -11,7 +11,6 @@ import js2xml from 'js2xmlparser';
|
||||
import Pageres from 'pageres';
|
||||
import nconf from 'nconf';
|
||||
import got from 'got';
|
||||
import Bluebird from 'bluebird';
|
||||
import md from 'habitica-markdown';
|
||||
import {
|
||||
S3,
|
||||
@@ -244,7 +243,7 @@ api.exportUserAvatarPng = {
|
||||
Body: stream,
|
||||
});
|
||||
|
||||
let s3res = await new Bluebird((resolve, reject) => {
|
||||
let s3res = await new Promise((resolve, reject) => {
|
||||
s3upload.send((err, s3uploadRes) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
|
||||
@@ -7,12 +7,6 @@ if (process.env.NODE_ENV !== 'production') {
|
||||
require('babel-register');
|
||||
}
|
||||
|
||||
// The BabelJS polyfill is needed in production too
|
||||
require('babel-polyfill');
|
||||
|
||||
// Setup Bluebird as the global promise library
|
||||
global.Promise = require('bluebird');
|
||||
|
||||
// Initialize configuration BEFORE anything
|
||||
const setupNconf = require('./libs/setupNconf');
|
||||
setupNconf();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import amazonPayments from 'amazon-payments';
|
||||
import nconf from 'nconf';
|
||||
import Bluebird from 'bluebird';
|
||||
import moment from 'moment';
|
||||
import cc from 'coupon-code';
|
||||
import uuid from 'uuid';
|
||||
import util from 'util';
|
||||
|
||||
import common from '../../common';
|
||||
import {
|
||||
@@ -51,15 +51,15 @@ api.constants = {
|
||||
PAYMENT_METHOD_GIFT: 'Amazon Payments (Gift)',
|
||||
};
|
||||
|
||||
api.getTokenInfo = Bluebird.promisify(amzPayment.api.getTokenInfo, {context: amzPayment.api});
|
||||
api.createOrderReferenceId = Bluebird.promisify(amzPayment.offAmazonPayments.createOrderReferenceForId, {context: amzPayment.offAmazonPayments});
|
||||
api.setOrderReferenceDetails = Bluebird.promisify(amzPayment.offAmazonPayments.setOrderReferenceDetails, {context: amzPayment.offAmazonPayments});
|
||||
api.confirmOrderReference = Bluebird.promisify(amzPayment.offAmazonPayments.confirmOrderReference, {context: amzPayment.offAmazonPayments});
|
||||
api.closeOrderReference = Bluebird.promisify(amzPayment.offAmazonPayments.closeOrderReference, {context: amzPayment.offAmazonPayments});
|
||||
api.setBillingAgreementDetails = Bluebird.promisify(amzPayment.offAmazonPayments.setBillingAgreementDetails, {context: amzPayment.offAmazonPayments});
|
||||
api.getBillingAgreementDetails = Bluebird.promisify(amzPayment.offAmazonPayments.getBillingAgreementDetails, {context: amzPayment.offAmazonPayments});
|
||||
api.confirmBillingAgreement = Bluebird.promisify(amzPayment.offAmazonPayments.confirmBillingAgreement, {context: amzPayment.offAmazonPayments});
|
||||
api.closeBillingAgreement = Bluebird.promisify(amzPayment.offAmazonPayments.closeBillingAgreement, {context: amzPayment.offAmazonPayments});
|
||||
api.getTokenInfo = util.promisify(amzPayment.api.getTokenInfo).bind(amzPayment.api);
|
||||
api.createOrderReferenceId = util.promisify(amzPayment.offAmazonPayments.createOrderReferenceForId).bind(amzPayment.offAmazonPayments);
|
||||
api.setOrderReferenceDetails = util.promisify(amzPayment.offAmazonPayments.setOrderReferenceDetails).bind(amzPayment.offAmazonPayments);
|
||||
api.confirmOrderReference = util.promisify(amzPayment.offAmazonPayments.confirmOrderReference).bind(amzPayment.offAmazonPayments);
|
||||
api.closeOrderReference = util.promisify(amzPayment.offAmazonPayments.closeOrderReference).bind(amzPayment.offAmazonPayments);
|
||||
api.setBillingAgreementDetails = util.promisify(amzPayment.offAmazonPayments.setBillingAgreementDetails).bind(amzPayment.offAmazonPayments);
|
||||
api.getBillingAgreementDetails = util.promisify(amzPayment.offAmazonPayments.getBillingAgreementDetails).bind(amzPayment.offAmazonPayments);
|
||||
api.confirmBillingAgreement = util.promisify(amzPayment.offAmazonPayments.confirmBillingAgreement).bind(amzPayment.offAmazonPayments);
|
||||
api.closeBillingAgreement = util.promisify(amzPayment.offAmazonPayments.closeBillingAgreement).bind(amzPayment.offAmazonPayments);
|
||||
|
||||
api.authorizeOnBillingAgreement = function authorizeOnBillingAgreement (inputSet) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* eslint-disable camelcase */
|
||||
import nconf from 'nconf';
|
||||
import Amplitude from 'amplitude';
|
||||
import Bluebird from 'bluebird';
|
||||
import googleAnalytics from 'universal-analytics';
|
||||
import useragent from 'useragent';
|
||||
import {
|
||||
@@ -171,7 +170,7 @@ let _sendDataToAmplitude = (eventType, data) => {
|
||||
|
||||
amplitudeData.event_type = eventType;
|
||||
|
||||
return new Bluebird((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
amplitude.track(amplitudeData)
|
||||
.then(resolve)
|
||||
.catch(() => reject('Error while sending data to Amplitude.'));
|
||||
@@ -222,7 +221,7 @@ let _sendDataToGoogle = (eventType, data) => {
|
||||
eventData.ev = value;
|
||||
}
|
||||
|
||||
return new Bluebird((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ga.event(eventData, (err) => {
|
||||
if (err) return reject(err);
|
||||
resolve();
|
||||
@@ -236,7 +235,7 @@ let _sendPurchaseDataToAmplitude = (data) => {
|
||||
amplitudeData.event_type = 'purchase';
|
||||
amplitudeData.revenue = data.purchaseValue;
|
||||
|
||||
return new Bluebird((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
amplitude.track(amplitudeData)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
@@ -261,7 +260,7 @@ let _sendPurchaseDataToGoogle = (data) => {
|
||||
ev: price,
|
||||
};
|
||||
|
||||
return new Bluebird((resolve) => {
|
||||
return new Promise((resolve) => {
|
||||
ga.event(eventData).send();
|
||||
|
||||
ga.transaction(data.uuid, price)
|
||||
@@ -273,14 +272,14 @@ let _sendPurchaseDataToGoogle = (data) => {
|
||||
};
|
||||
|
||||
function track (eventType, data) {
|
||||
return Bluebird.all([
|
||||
return Promise.all([
|
||||
_sendDataToAmplitude(eventType, data),
|
||||
_sendDataToGoogle(eventType, data),
|
||||
]);
|
||||
}
|
||||
|
||||
function trackPurchase (data) {
|
||||
return Bluebird.all([
|
||||
return Promise.all([
|
||||
_sendPurchaseDataToAmplitude(data),
|
||||
_sendPurchaseDataToGoogle(data),
|
||||
]);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Currently this holds helpers for challenge api, but we should break this up into submodules as it expands
|
||||
import omit from 'lodash/omit';
|
||||
import uuid from 'uuid';
|
||||
import Bluebird from 'bluebird';
|
||||
import { model as Challenge } from '../../models/challenge';
|
||||
import {
|
||||
model as Group,
|
||||
@@ -82,7 +81,7 @@ export async function createChallenge (user, req, res) {
|
||||
|
||||
addUserJoinChallengeNotification(user);
|
||||
|
||||
let results = await Bluebird.all([challenge.save({
|
||||
let results = await Promise.all([challenge.save({
|
||||
validateBeforeSave: false, // already validate
|
||||
}), group.save()]);
|
||||
let savedChal = results[0];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import moment from 'moment';
|
||||
import Bluebird from 'bluebird';
|
||||
import { model as User } from '../models/user';
|
||||
import common from '../../common/';
|
||||
import { preenUserHistory } from '../libs/preening';
|
||||
import sleep from '../libs/sleep';
|
||||
import _ from 'lodash';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import nconf from 'nconf';
|
||||
@@ -29,7 +29,7 @@ function setIsDueNextDue (task, user, now) {
|
||||
export async function recoverCron (status, locals) {
|
||||
let {user} = locals;
|
||||
|
||||
await Bluebird.delay(300);
|
||||
await sleep(0.3);
|
||||
|
||||
let reloadedUser = await User.findOne({_id: user._id}).exec();
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import csvStringify from 'csv-stringify';
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
module.exports = (input) => {
|
||||
return new Bluebird((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
csvStringify(input, (err, output) => {
|
||||
if (err) return reject(err);
|
||||
return resolve(output);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import nconf from 'nconf';
|
||||
import util from 'util';
|
||||
import iap from 'in-app-purchase';
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
// Validation ERROR Codes
|
||||
// const INVALID_PAYLOAD = 6778001;
|
||||
@@ -18,8 +18,8 @@ iap.config({
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
setup: Bluebird.promisify(iap.setup, { context: iap }),
|
||||
validate: Bluebird.promisify(iap.validate, { context: iap }),
|
||||
setup: util.promisify(iap.setup.bind(iap)),
|
||||
validate: util.promisify(iap.validate.bind(iap)),
|
||||
isValidated: iap.isValidated,
|
||||
getPurchaseData: iap.getPurchaseData,
|
||||
GOOGLE: iap.GOOGLE,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* eslint-disable camelcase */
|
||||
import nconf from 'nconf';
|
||||
import moment from 'moment';
|
||||
import util from 'util';
|
||||
import _ from 'lodash';
|
||||
import payments from './payments';
|
||||
import ipn from 'paypal-ipn';
|
||||
import paypal from 'paypal-rest-sdk';
|
||||
import shared from '../../common';
|
||||
import cc from 'coupon-code';
|
||||
import Bluebird from 'bluebird';
|
||||
import { model as Coupon } from '../models/coupon';
|
||||
import { model as User } from '../models/user';
|
||||
import {
|
||||
@@ -60,14 +60,14 @@ api.constants = {
|
||||
// PAYMENT_METHOD_GIFT: 'Amazon Payments (Gift)',
|
||||
};
|
||||
|
||||
api.paypalPaymentCreate = Bluebird.promisify(paypal.payment.create, {context: paypal.payment});
|
||||
api.paypalPaymentExecute = Bluebird.promisify(paypal.payment.execute, {context: paypal.payment});
|
||||
api.paypalBillingAgreementCreate = Bluebird.promisify(paypal.billingAgreement.create, {context: paypal.billingAgreement});
|
||||
api.paypalBillingAgreementExecute = Bluebird.promisify(paypal.billingAgreement.execute, {context: paypal.billingAgreement});
|
||||
api.paypalBillingAgreementGet = Bluebird.promisify(paypal.billingAgreement.get, {context: paypal.billingAgreement});
|
||||
api.paypalBillingAgreementCancel = Bluebird.promisify(paypal.billingAgreement.cancel, {context: paypal.billingAgreement});
|
||||
api.paypalPaymentCreate = util.promisify(paypal.payment.create.bind(paypal.payment));
|
||||
api.paypalPaymentExecute = util.promisify(paypal.payment.execute.bind(paypal.payment));
|
||||
api.paypalBillingAgreementCreate = util.promisify(paypal.billingAgreement.create.bind(paypal.billingAgreement));
|
||||
api.paypalBillingAgreementExecute = util.promisify(paypal.billingAgreement.execute.bind(paypal.billingAgreement));
|
||||
api.paypalBillingAgreementGet = util.promisify(paypal.billingAgreement.get.bind(paypal.billingAgreement));
|
||||
api.paypalBillingAgreementCancel = util.promisify(paypal.billingAgreement.cancel.bind(paypal.billingAgreement));
|
||||
|
||||
api.ipnVerifyAsync = Bluebird.promisify(ipn.verify, {context: ipn});
|
||||
api.ipnVerifyAsync = util.promisify(ipn.verify.bind(ipn));
|
||||
|
||||
api.checkout = async function checkout (options = {}) {
|
||||
let {gift, user} = options;
|
||||
|
||||
@@ -3,7 +3,6 @@ import nconf from 'nconf';
|
||||
// @TODO remove this lib and use directly the apn module
|
||||
import pushNotify from 'push-notify';
|
||||
import logger from './logger';
|
||||
import Bluebird from 'bluebird';
|
||||
import {
|
||||
S3,
|
||||
} from './aws';
|
||||
@@ -20,7 +19,7 @@ const APN_ENABLED = nconf.get('PUSH_CONFIGS:APN_ENABLED') === 'true';
|
||||
const S3_BUCKET = nconf.get('S3:bucket');
|
||||
|
||||
if (APN_ENABLED) {
|
||||
Bluebird.all([
|
||||
Promise.all([
|
||||
S3.getObject({
|
||||
Bucket: S3_BUCKET,
|
||||
Key: 'apple_apn/cert.pem',
|
||||
|
||||
7
website/server/libs/sleep.js
Normal file
7
website/server/libs/sleep.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export default async function (seconds = 1) {
|
||||
let milliseconds = seconds * 1000;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, milliseconds);
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
import { model as User } from '../models/user';
|
||||
import * as Tasks from '../models/task';
|
||||
import {
|
||||
@@ -24,7 +22,7 @@ async function castTaskSpell (res, req, targetId, user, spell, quantity = 1) {
|
||||
spell.cast(user, task, req);
|
||||
}
|
||||
|
||||
const results = await Bluebird.all([
|
||||
const results = await Promise.all([
|
||||
user.save(),
|
||||
task.save(),
|
||||
]);
|
||||
@@ -46,7 +44,7 @@ async function castMultiTaskSpell (req, user, spell, quantity = 1) {
|
||||
.filter(t => t.isModified())
|
||||
.map(t => t.save());
|
||||
toSave.unshift(user.save());
|
||||
const saved = await Bluebird.all(toSave);
|
||||
const saved = await Promise.all(toSave);
|
||||
|
||||
const response = {
|
||||
tasks: saved,
|
||||
@@ -82,7 +80,7 @@ async function castPartySpell (req, party, partyMembers, user, spell, quantity =
|
||||
for (let i = 0; i < quantity; i += 1) {
|
||||
spell.cast(user, partyMembers, req);
|
||||
}
|
||||
await Bluebird.all(partyMembers.map(m => m.save()));
|
||||
await Promise.all(partyMembers.map(m => m.save()));
|
||||
|
||||
return partyMembers;
|
||||
}
|
||||
@@ -107,7 +105,7 @@ async function castUserSpell (res, req, party, partyMembers, targetId, user, spe
|
||||
}
|
||||
|
||||
if (partyMembers !== user) {
|
||||
await Bluebird.all([
|
||||
await Promise.all([
|
||||
user.save(),
|
||||
partyMembers.save(),
|
||||
]);
|
||||
|
||||
@@ -3,7 +3,6 @@ import * as Tasks from '../models/task';
|
||||
import {
|
||||
BadRequest,
|
||||
} from './errors';
|
||||
import Bluebird from 'bluebird';
|
||||
import _ from 'lodash';
|
||||
import shared from '../../common';
|
||||
|
||||
@@ -18,9 +17,9 @@ async function _validateTaskAlias (tasks, res) {
|
||||
throw new BadRequest(res.t('taskAliasAlreadyUsed'));
|
||||
}
|
||||
|
||||
await Bluebird.map(tasksWithAliases, (task) => {
|
||||
await Promise.all(tasksWithAliases.map((task) => {
|
||||
return task.validate();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
export function setNextDue (task, user, dueDateOption) {
|
||||
@@ -137,7 +136,7 @@ export async function createTasks (req, res, options = {}) {
|
||||
|
||||
toSave.unshift(owner.save());
|
||||
|
||||
let tasks = await Bluebird.all(toSave);
|
||||
let tasks = await Promise.all(toSave);
|
||||
tasks.splice(0, 1); // Remove user, challenge, or group promise
|
||||
return tasks;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import moment from 'moment';
|
||||
import * as Tasks from '../models/task';
|
||||
import Bluebird from 'bluebird';
|
||||
import { model as Group } from '../models/group';
|
||||
import { model as User } from '../models/user';
|
||||
import { recoverCron, cron } from '../libs/cron';
|
||||
@@ -99,7 +98,7 @@ async function cronAsync (req, res) {
|
||||
tasks.forEach(task => {
|
||||
if (task.isModified()) toSave.push(task.save());
|
||||
});
|
||||
await Bluebird.all(toSave);
|
||||
await Promise.all(toSave);
|
||||
|
||||
await Group.processQuestProgress(user, progress);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import mongoose from 'mongoose';
|
||||
import Bluebird from 'bluebird';
|
||||
import validator from 'validator';
|
||||
import baseModel from '../libs/baseModel';
|
||||
import _ from 'lodash';
|
||||
@@ -120,7 +119,7 @@ schema.methods.syncToUser = async function syncChallengeToUser (user) {
|
||||
});
|
||||
}
|
||||
|
||||
let [challengeTasks, userTasks] = await Bluebird.all([
|
||||
let [challengeTasks, userTasks] = await Promise.all([
|
||||
// Find original challenge tasks
|
||||
Tasks.Task.find({
|
||||
userId: {$exists: false},
|
||||
@@ -165,7 +164,7 @@ schema.methods.syncToUser = async function syncChallengeToUser (user) {
|
||||
});
|
||||
|
||||
toSave.push(user.save());
|
||||
return Bluebird.all(toSave);
|
||||
return Promise.all(toSave);
|
||||
};
|
||||
|
||||
async function _fetchMembersIds (challengeId) {
|
||||
@@ -202,7 +201,7 @@ async function _addTaskFn (challenge, tasks, memberId) {
|
||||
|
||||
// Update the user
|
||||
toSave.unshift(User.update({_id: memberId}, updateTasksOrderQ).exec());
|
||||
return await Bluebird.all(toSave);
|
||||
return await Promise.all(toSave);
|
||||
}
|
||||
|
||||
// Add a new task to challenge members
|
||||
@@ -210,11 +209,11 @@ schema.methods.addTasks = async function challengeAddTasks (tasks) {
|
||||
let challenge = this;
|
||||
let membersIds = await _fetchMembersIds(challenge._id);
|
||||
|
||||
let queue = new TaskQueue(Bluebird, 25); // process only 5 users concurrently
|
||||
let queue = new TaskQueue(Promise, 25); // process only 5 users concurrently
|
||||
|
||||
await Bluebird.map(membersIds, queue.wrap((memberId) => {
|
||||
await Promise.all(membersIds.map(queue.wrap((memberId) => {
|
||||
return _addTaskFn(challenge, tasks, memberId);
|
||||
}));
|
||||
})));
|
||||
};
|
||||
|
||||
// Sync updated task to challenge members
|
||||
@@ -267,7 +266,7 @@ schema.methods.unlinkTasks = async function challengeUnlinkTasks (user, keep) {
|
||||
$set: {challenge: {}},
|
||||
}, {multi: true}).exec();
|
||||
|
||||
return Bluebird.all([user.save(), this.save()]);
|
||||
return Promise.all([user.save(), this.save()]);
|
||||
} else { // keep = 'remove-all'
|
||||
let tasks = await Tasks.Task.find(findQuery).select('_id type completed').exec();
|
||||
let taskPromises = tasks.map(task => {
|
||||
@@ -280,7 +279,7 @@ schema.methods.unlinkTasks = async function challengeUnlinkTasks (user, keep) {
|
||||
});
|
||||
user.markModified('tasksOrder');
|
||||
taskPromises.push(user.save(), this.save());
|
||||
return Bluebird.all(taskPromises);
|
||||
return Promise.all(taskPromises);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -358,7 +357,7 @@ schema.methods.closeChal = async function closeChal (broken = {}) {
|
||||
}, {multi: true}).exec(),
|
||||
];
|
||||
|
||||
Bluebird.all(backgroundTasks);
|
||||
Promise.all(backgroundTasks);
|
||||
};
|
||||
|
||||
export let model = mongoose.model('Challenge', schema);
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
} from '../libs/errors';
|
||||
import baseModel from '../libs/baseModel';
|
||||
import { sendTxn as sendTxnEmail } from '../libs/email';
|
||||
import Bluebird from 'bluebird';
|
||||
import nconf from 'nconf';
|
||||
import { sendNotification as sendPushNotification } from '../libs/pushNotifications';
|
||||
import pusher from '../libs/pusher';
|
||||
@@ -308,7 +307,7 @@ schema.statics.getGroups = async function getGroups (options = {}) {
|
||||
}
|
||||
});
|
||||
|
||||
let groupsArray = _.reduce(await Bluebird.all(queries), (previousValue, currentValue) => {
|
||||
let groupsArray = _.reduce(await Promise.all(queries), (previousValue, currentValue) => {
|
||||
if (_.isEmpty(currentValue)) return previousValue; // don't add anything to the results if the query returned null or an empty array
|
||||
return previousValue.concat(Array.isArray(currentValue) ? currentValue : [currentValue]); // otherwise concat the new results to the previousValue
|
||||
}, []);
|
||||
@@ -427,7 +426,7 @@ schema.methods.removeGroupInvitations = async function removeGroupInvitations ()
|
||||
return user.save();
|
||||
});
|
||||
|
||||
return Bluebird.all(userUpdates);
|
||||
return Promise.all(userUpdates);
|
||||
};
|
||||
|
||||
// Return true if user is a member of the group
|
||||
@@ -628,13 +627,18 @@ schema.methods.startQuest = async function startQuest (user) {
|
||||
// remove any users from quest.members who aren't in the party
|
||||
let partyId = this._id;
|
||||
let questMembers = this.quest.members;
|
||||
await Bluebird.map(Object.keys(this.quest.members), async (memberId) => {
|
||||
let member = await User.findOne({_id: memberId, 'party._id': partyId}).select('_id').lean().exec();
|
||||
|
||||
await Promise.all(Object.keys(this.quest.members).map(memberId => {
|
||||
return User.findOne({_id: memberId, 'party._id': partyId})
|
||||
.select('_id')
|
||||
.lean()
|
||||
.exec()
|
||||
.then((member) => {
|
||||
if (!member) {
|
||||
delete questMembers[memberId];
|
||||
}
|
||||
return;
|
||||
});
|
||||
}));
|
||||
|
||||
if (userIsParticipating) {
|
||||
user.party.quest.key = this.quest.key;
|
||||
@@ -871,7 +875,7 @@ schema.methods.finishQuest = async function finishQuest (quest) {
|
||||
}));
|
||||
}
|
||||
|
||||
return Bluebird.all(promises);
|
||||
return Promise.all(promises);
|
||||
};
|
||||
|
||||
function _isOnQuest (user, progress, group) {
|
||||
@@ -1123,7 +1127,7 @@ schema.methods.leave = async function leaveGroup (user, keep = 'keep-all', keepC
|
||||
let challengesToRemoveUserFrom = challenges.map(chal => {
|
||||
return chal.unlinkTasks(user, keep);
|
||||
});
|
||||
await Bluebird.all(challengesToRemoveUserFrom);
|
||||
await Promise.all(challengesToRemoveUserFrom);
|
||||
}
|
||||
|
||||
// Unlink group tasks)
|
||||
@@ -1135,7 +1139,7 @@ schema.methods.leave = async function leaveGroup (user, keep = 'keep-all', keepC
|
||||
let assignedTasksToRemoveUserFrom = assignedTasks.map(task => {
|
||||
return this.unlinkTask(task, user, keep);
|
||||
});
|
||||
await Bluebird.all(assignedTasksToRemoveUserFrom);
|
||||
await Promise.all(assignedTasksToRemoveUserFrom);
|
||||
|
||||
let promises = [];
|
||||
|
||||
@@ -1171,7 +1175,7 @@ schema.methods.leave = async function leaveGroup (user, keep = 'keep-all', keepC
|
||||
|
||||
if (members.length === 0) {
|
||||
promises.push(group.remove());
|
||||
return await Bluebird.all(promises);
|
||||
return await Promise.all(promises);
|
||||
}
|
||||
} else if (group.leader === user._id) { // otherwise If the leader is leaving (or if the leader previously left, and this wasn't accounted for)
|
||||
let query = group.type === 'party' ? {'party._id': group._id} : {guilds: group._id};
|
||||
@@ -1193,7 +1197,7 @@ schema.methods.leave = async function leaveGroup (user, keep = 'keep-all', keepC
|
||||
}
|
||||
promises.push(group.update(update).exec());
|
||||
|
||||
return await Bluebird.all(promises);
|
||||
return await Promise.all(promises);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1327,7 +1331,7 @@ schema.methods.syncTask = async function groupSyncTask (taskToSync, user) {
|
||||
if (matchingTask.tags.indexOf(group._id) === -1) matchingTask.tags.push(group._id); // add tag if missing
|
||||
|
||||
toSave.push(matchingTask.save(), taskToSync.save(), user.save());
|
||||
return Bluebird.all(toSave);
|
||||
return Promise.all(toSave);
|
||||
};
|
||||
|
||||
schema.methods.unlinkTask = async function groupUnlinkTask (unlinkingTask, user, keep) {
|
||||
@@ -1353,7 +1357,7 @@ schema.methods.unlinkTask = async function groupUnlinkTask (unlinkingTask, user,
|
||||
user.markModified('tasksOrder');
|
||||
}
|
||||
|
||||
return Bluebird.all([task.remove(), user.save(), unlinkingTask.save()]);
|
||||
return Promise.all([task.remove(), user.save(), unlinkingTask.save()]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import common from '../../../common';
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
import Bluebird from 'bluebird';
|
||||
import baseModel from '../../libs/baseModel';
|
||||
import * as Tasks from '../task';
|
||||
import {
|
||||
@@ -58,7 +57,7 @@ function _populateDefaultTasks (user, taskTypes) {
|
||||
// @TODO: default tasks are handled differently now, and not during registration. We should move this code
|
||||
|
||||
let tasksToCreate = [];
|
||||
if (user.registeredThrough === 'habitica-web') return Bluebird.all(tasksToCreate);
|
||||
if (user.registeredThrough === 'habitica-web') return Promise.all(tasksToCreate);
|
||||
|
||||
if (tagsI !== -1) {
|
||||
taskTypes = _.clone(taskTypes);
|
||||
@@ -89,7 +88,7 @@ function _populateDefaultTasks (user, taskTypes) {
|
||||
tasksToCreate.push(...tasksOfType);
|
||||
});
|
||||
|
||||
return Bluebird.all(tasksToCreate)
|
||||
return Promise.all(tasksToCreate)
|
||||
.then((tasksCreated) => {
|
||||
_.each(tasksCreated, (task) => {
|
||||
user.tasksOrder[`${task.type}s`].push(task._id);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import moment from 'moment';
|
||||
import common from '../../../common';
|
||||
|
||||
import Bluebird from 'bluebird';
|
||||
import {
|
||||
chatDefaults,
|
||||
TAVERN_ID,
|
||||
@@ -132,7 +131,7 @@ schema.methods.sendMessage = async function sendMessage (userToReceiveMessage, o
|
||||
sender.markModified('inbox.messages');
|
||||
|
||||
let promises = [userToReceiveMessage.save(), sender.save()];
|
||||
await Bluebird.all(promises);
|
||||
await Promise.all(promises);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,9 +2,6 @@ import nconf from 'nconf';
|
||||
import logger from './libs/logger';
|
||||
import express from 'express';
|
||||
import http from 'http';
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
global.Promise = Bluebird;
|
||||
|
||||
const server = http.createServer();
|
||||
const app = express();
|
||||
|
||||
Reference in New Issue
Block a user