chore: Delete unrequired files
This commit is contained in:
committed by
mrugesh mohapatra
parent
36d150cbe1
commit
f441b1fe1c
@ -1,25 +0,0 @@
|
|||||||
require('dotenv').load();
|
|
||||||
const pm2 = require('pm2');
|
|
||||||
|
|
||||||
const instances = process.env.INSTANCES || 1;
|
|
||||||
const serverName = process.env.SERVER_NAME || 'server';
|
|
||||||
const maxMemory = process.env.MAX_MEMORY || '390M';
|
|
||||||
|
|
||||||
pm2.connect(function() {
|
|
||||||
pm2.start({
|
|
||||||
name: serverName,
|
|
||||||
script: 'server/production-start.js',
|
|
||||||
exec_mode: 'cluster',
|
|
||||||
instances: instances,
|
|
||||||
max_memory_restart: maxMemory,
|
|
||||||
NODE_ENV: 'production'
|
|
||||||
}, function() {
|
|
||||||
console.log(
|
|
||||||
'pm2 started %s with %s instances at %s max memory',
|
|
||||||
serverName,
|
|
||||||
instances,
|
|
||||||
maxMemory
|
|
||||||
);
|
|
||||||
pm2.disconnect();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,58 +0,0 @@
|
|||||||
import debug from 'debug';
|
|
||||||
import { pickBy } from 'lodash';
|
|
||||||
import { Observable } from 'rx';
|
|
||||||
|
|
||||||
import { cachedMap, getChallenge } from '../utils/map';
|
|
||||||
import { shapeChallenges } from '../../common/app/redux/utils';
|
|
||||||
|
|
||||||
const log = debug('fcc:services:challenge');
|
|
||||||
const isDev = debug.enabled('fcc:*');
|
|
||||||
|
|
||||||
export default function getChallengesForBlock(app) {
|
|
||||||
const challengeMap = cachedMap(app.models);
|
|
||||||
return {
|
|
||||||
name: 'challenge',
|
|
||||||
read: function readChallengesForBlock(
|
|
||||||
req,
|
|
||||||
resource,
|
|
||||||
{ dashedName, blockName} = {},
|
|
||||||
config,
|
|
||||||
cb
|
|
||||||
) {
|
|
||||||
const getChallengeBlock$ = challengeMap
|
|
||||||
.flatMap(({
|
|
||||||
result: { superBlocks },
|
|
||||||
entities: {
|
|
||||||
block: fullBlockMap,
|
|
||||||
challenge: challengeMap
|
|
||||||
}
|
|
||||||
}) => {
|
|
||||||
log(`sourcing challenges for the ${blockName} block`);
|
|
||||||
const requestedChallenges = pickBy(
|
|
||||||
challengeMap,
|
|
||||||
ch => ch.block === blockName
|
|
||||||
);
|
|
||||||
const entities = {
|
|
||||||
block: {
|
|
||||||
[blockName]: fullBlockMap[blockName]
|
|
||||||
},
|
|
||||||
challenge: requestedChallenges
|
|
||||||
};
|
|
||||||
const { challenge, block } = shapeChallenges(entities, isDev);
|
|
||||||
return Observable.of({
|
|
||||||
result: { superBlocks },
|
|
||||||
entities: { challenge, block }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return Observable.if(
|
|
||||||
() => !!dashedName,
|
|
||||||
getChallenge(dashedName, blockName, challengeMap, 'en'),
|
|
||||||
getChallengeBlock$
|
|
||||||
)
|
|
||||||
.subscribe(
|
|
||||||
result => cb(null, result),
|
|
||||||
cb
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
import debug from 'debug';
|
|
||||||
import { Observable } from 'rx';
|
|
||||||
|
|
||||||
import { cachedMap } from '../utils/map';
|
|
||||||
|
|
||||||
const log = debug('fcc:services:mapUi');
|
|
||||||
|
|
||||||
|
|
||||||
export default function mapUiService(app) {
|
|
||||||
const challengeMap = cachedMap(app.models);
|
|
||||||
return {
|
|
||||||
name: 'map-ui',
|
|
||||||
read: function readMapUi(req, resource, _, config, cb) {
|
|
||||||
return challengeMap
|
|
||||||
.flatMap(({
|
|
||||||
result: { superBlocks },
|
|
||||||
entities: {
|
|
||||||
superBlock: fullSuperBlockMap,
|
|
||||||
block: fullBlockMap,
|
|
||||||
challenge: fullChallengeMap
|
|
||||||
}
|
|
||||||
}) => {
|
|
||||||
const superBlockMap = superBlocks
|
|
||||||
.map(superBlock => fullSuperBlockMap[superBlock])
|
|
||||||
.reduce((map, { dashedName, blocks, title }) => {
|
|
||||||
map[dashedName] = { blocks, title, dashedName};
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
const blockMap = Object.keys(fullBlockMap)
|
|
||||||
.map(block => fullBlockMap[block])
|
|
||||||
.reduce(
|
|
||||||
(map, { dashedName, title, time, challenges, superBlock }) => {
|
|
||||||
map[dashedName] = {
|
|
||||||
dashedName,
|
|
||||||
title,
|
|
||||||
time,
|
|
||||||
challenges,
|
|
||||||
superBlock
|
|
||||||
};
|
|
||||||
return map;
|
|
||||||
},
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
const challengeMap = Object.keys(fullChallengeMap)
|
|
||||||
.map(challenge => fullChallengeMap[challenge])
|
|
||||||
.reduce((map, challenge) => {
|
|
||||||
const {
|
|
||||||
dashedName,
|
|
||||||
id,
|
|
||||||
title,
|
|
||||||
name,
|
|
||||||
block,
|
|
||||||
isLocked,
|
|
||||||
isComingSoon,
|
|
||||||
isBeta,
|
|
||||||
challengeType
|
|
||||||
} = challenge;
|
|
||||||
map[dashedName] = {
|
|
||||||
dashedName,
|
|
||||||
id,
|
|
||||||
title,
|
|
||||||
name,
|
|
||||||
block,
|
|
||||||
isLocked,
|
|
||||||
isComingSoon,
|
|
||||||
isBeta,
|
|
||||||
challengeType
|
|
||||||
};
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
const mapUi = {
|
|
||||||
result: { superBlocks },
|
|
||||||
entities: {
|
|
||||||
superBlock: superBlockMap,
|
|
||||||
block: blockMap,
|
|
||||||
challenge: challengeMap
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return Observable.of(mapUi);
|
|
||||||
}).subscribe(
|
|
||||||
mapUi => cb(null, mapUi ),
|
|
||||||
err => { log(err); return cb(err); }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Any ref to fixCompletedChallengesItem should be removed post
|
|
||||||
* a db migration to fix all completedChallenges
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Observable } from 'rx';
|
|
||||||
import _ from 'lodash';
|
|
||||||
|
|
||||||
import {
|
|
||||||
getProgress,
|
|
||||||
normaliseUserFields,
|
|
||||||
userPropsForSession
|
|
||||||
} from '../utils/publicUserProps';
|
|
||||||
import { fixCompletedChallengeItem } from '../../common/utils';
|
|
||||||
|
|
||||||
export default function userServices() {
|
|
||||||
return {
|
|
||||||
name: 'user',
|
|
||||||
read: function readUserService(
|
|
||||||
req,
|
|
||||||
resource,
|
|
||||||
params,
|
|
||||||
config,
|
|
||||||
cb) {
|
|
||||||
const queryUser = req.user;
|
|
||||||
const source = queryUser && Observable.forkJoin(
|
|
||||||
queryUser.getCompletedChallenges$(),
|
|
||||||
queryUser.getPoints$(),
|
|
||||||
(completedChallenges, progressTimestamps) => ({
|
|
||||||
completedChallenges,
|
|
||||||
progress: getProgress(progressTimestamps, queryUser.timezone)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
Observable.if(
|
|
||||||
() => !queryUser,
|
|
||||||
Observable.of({}),
|
|
||||||
Observable.defer(() => source)
|
|
||||||
.map(({ completedChallenges, progress }) => ({
|
|
||||||
...queryUser.toJSON(),
|
|
||||||
...progress,
|
|
||||||
completedChallenges: completedChallenges.map(
|
|
||||||
fixCompletedChallengeItem
|
|
||||||
)
|
|
||||||
}))
|
|
||||||
.map(
|
|
||||||
user => ({
|
|
||||||
entities: {
|
|
||||||
user: {
|
|
||||||
[user.username]: {
|
|
||||||
..._.pick(user, userPropsForSession),
|
|
||||||
isEmailVerified: !!user.emailVerified,
|
|
||||||
isGithub: !!user.githubProfile,
|
|
||||||
isLinkedIn: !!user.linkedin,
|
|
||||||
isTwitter: !!user.twitter,
|
|
||||||
isWebsite: !!user.website,
|
|
||||||
...normaliseUserFields(user)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
result: user.username
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.subscribe(
|
|
||||||
user => cb(null, user),
|
|
||||||
cb
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
Reference in New Issue
Block a user