fix: Use module.exports instead of export default

This commit is contained in:
Blade Barringer
2016-03-04 13:29:51 -06:00
parent 4cd0428f0a
commit b97511db31
34 changed files with 53 additions and 53 deletions

View File

@@ -166,7 +166,7 @@ function _changeTaskValue (user, task, direction, times, cron) {
return addToDelta;
}
export default function scoreTask (options = {}, req = {}) {
module.exports = function scoreTask (options = {}, req = {}) {
let {user, task, direction, times = 1, cron = false} = options;
let delta = 0;
let stats = {
@@ -247,4 +247,4 @@ export default function scoreTask (options = {}, req = {}) {
user.fns.updateStats(stats, req);
return delta;
}
};

View File

@@ -342,4 +342,4 @@ api.logout = {
},
};
export default api;
module.exports = api;

View File

@@ -565,4 +565,4 @@ api.selectChallengeWinner = {
},
};
export default api;
module.exports = api;

View File

@@ -392,4 +392,4 @@ api.deleteChat = {
},
};
export default api;
module.exports = api;

View File

@@ -226,4 +226,4 @@ api.exportUserAvatarPng = {
},
};
export default api;
module.exports = api;

View File

@@ -51,4 +51,4 @@ api.unsubscribe = {
},
};
export default api;
module.exports = api;

View File

@@ -497,12 +497,12 @@ async function _inviteByUUID (uuid, group, inviter, req, res) {
if (group.type === 'guild') {
emailVars.push(
{name: 'GUILD_NAME', content: group.name},
{name: 'GUILD_URL', content: '/#/options/groups/guilds/public'},
{name: 'GUILD_URL', content: '/#/options/groups/guilds/public'}
);
} else {
emailVars.push(
{name: 'PARTY_NAME', content: group.name},
{name: 'PARTY_URL', content: '/#/options/groups/party'},
{name: 'PARTY_URL', content: '/#/options/groups/party'}
);
}
@@ -642,4 +642,4 @@ api.inviteToGroup = {
},
};
export default api;
module.exports = api;

View File

@@ -189,4 +189,4 @@ api.updateHero = {
},
};
export default api;
module.exports = api;

View File

@@ -231,4 +231,4 @@ api.getChallengeMemberProgress = {
},
};
export default api;
module.exports = api;

View File

@@ -36,4 +36,4 @@ api.getModelPaths = {
},
};
export default api;
module.exports = api;

View File

@@ -448,4 +448,4 @@ api.leaveQuest = {
},
};
export default api;
module.exports = api;

View File

@@ -144,4 +144,4 @@ api.deleteTag = {
},
};
export default api;
module.exports = api;

View File

@@ -923,4 +923,4 @@ api.deleteTask = {
},
};
export default api;
module.exports = api;

View File

@@ -156,4 +156,4 @@ api.castSpell = {
},
};
export default api;
module.exports = api;

View File

@@ -231,7 +231,7 @@ let mockAnalyticsService = {
trackPurchase: () => { },
};
export default {
module.exports = {
track,
trackPurchase,
mockAnalyticsService,

View File

@@ -3,7 +3,7 @@ import validator from 'validator';
import objectPath from 'object-path'; // TODO use lodash's unset once v4 is out
import _ from 'lodash';
export default function baseModel (schema, options = {}) {
module.exports = function baseModel (schema, options = {}) {
schema.add({
_id: {
type: String,
@@ -67,4 +67,4 @@ export default function baseModel (schema, options = {}) {
return result;
}, {});
};
}
};

View File

@@ -1,11 +1,11 @@
import csvStringify from 'csv-stringify';
import Q from 'q';
export default function (input) {
module.exports = (input) => {
return Q.promise((resolve, reject) => {
csvStringify(input, (err, output) => {
if (err) return reject(err);
return resolve(output);
});
});
}
};

View File

@@ -21,4 +21,4 @@ if (IS_PROD) {
});
}
export default logger;
module.exports = logger;

View File

@@ -25,7 +25,7 @@ if (gcm) {
}
// TODO test
export default function sendNotification (user, title, message, timeToLive = 15) {
module.exports = function sendNotification (user, title, message, timeToLive = 15) {
// TODO need investigation:
// https://github.com/HabitRPG/habitrpg/issues/5252
@@ -54,4 +54,4 @@ export default function sendNotification (user, title, message, timeToLive = 15)
break;
}
});
}
};

View File

@@ -3,7 +3,7 @@ import { join, resolve } from 'path';
const PATH_TO_CONFIG = join(resolve(__dirname, '../../../../config.json'));
export default function setupNconf (file) {
module.exports = function setupNconf (file) {
let configFile = file || PATH_TO_CONFIG;
nconf
@@ -14,4 +14,4 @@ export default function setupNconf (file) {
nconf.set('IS_PROD', nconf.get('NODE_ENV') === 'production');
nconf.set('IS_DEV', nconf.get('NODE_ENV') === 'development');
nconf.set('IS_TEST', nconf.get('NODE_ENV') === 'test');
}
};

View File

@@ -31,4 +31,4 @@ function walkControllers (filePath) {
walkControllers(CONTROLLERS_PATH);
export default router;
module.exports = router;

View File

@@ -16,8 +16,8 @@ if (nconf.get('IS_PROD')) {
service = mockAnalyticsService;
}
export default function attachAnalytics (req, res, next) {
module.exports = function attachAnalytics (req, res, next) {
res.analytics = service;
next();
}
};

View File

@@ -269,7 +269,7 @@ export function cron (options = {}) {
}
// TODO check that it's used everywhere
export default async function cronMiddleware (req, res, next) {
module.exports = async function cronMiddleware (req, res, next) {
let user = res.locals.user;
let analytics = res.analytics;
@@ -335,4 +335,4 @@ export default async function cronMiddleware (req, res, next) {
.then(() => next())
.catch(next);
});
}
};

View File

@@ -3,7 +3,7 @@
// it's yet to be decided whether to keep it or not
import domainMiddleware from 'domain-middleware';
export default function implementDomainMiddleware (server, mongoose) {
module.exports = function implementDomainMiddleware (server, mongoose) {
return domainMiddleware({
server: {
close () {
@@ -13,4 +13,4 @@ export default function implementDomainMiddleware (server, mongoose) {
},
killTimeout: 10000,
});
}
};

View File

@@ -8,7 +8,7 @@ import {
} from '../../libs/api-v3/errors';
import { map } from 'lodash';
export default function errorHandler (err, req, res, next) { // eslint-disable-line no-unused-vars
module.exports = function errorHandler (err, req, res, next) { // eslint-disable-line no-unused-vars
// Log the original error with some metadata
let stack = err.stack || err.message || err;
@@ -77,4 +77,4 @@ export default function errorHandler (err, req, res, next) { // eslint-disable-l
// In some occasions like when invalid JSON is supplied `res.respond` might be not yet avalaible,
// in this case we use the standard res.status(...).json(...)
return res.respond ? res.respond(responseErr.httpCode, jsonRes) : res.status(responseErr.httpCode).json(jsonRes);
}
};

View File

@@ -64,7 +64,7 @@ function _attachTranslateFunction (req, res, next) {
next();
}
export default function getUserLanguage (req, res, next) {
module.exports = function getUserLanguage (req, res, next) {
if (req.query.lang) { // In case the language is specified in the request url, use it
req.language = translations[req.query.lang] ? req.query.lang : 'en';
return _attachTranslateFunction(...arguments);
@@ -85,4 +85,4 @@ export default function getUserLanguage (req, res, next) {
req.language = _getFromUser(null, req);
return _attachTranslateFunction(...arguments);
}
}
};

View File

@@ -18,7 +18,7 @@ const DISABLE_LOGGING = nconf.get('DISABLE_REQUEST_LOGGING');
const SESSION_SECRET = nconf.get('SESSION_SECRET');
const TWO_WEEKS = 1000 * 60 * 60 * 24 * 14;
export default function attachMiddlewares (app) {
module.exports = function attachMiddlewares (app) {
if (!IS_PROD && !DISABLE_LOGGING) app.use(morgan('dev'));
// TODO handle errors
@@ -45,4 +45,4 @@ export default function attachMiddlewares (app) {
// Error handler middleware, define as the last one
app.use(errorHandler);
}
};

View File

@@ -37,7 +37,7 @@ let env = {
env[key] = nconf.get(key);
});
export default function locals (req, res, next) {
module.exports = function locals (req, res, next) {
let language = _.find(i18n.availableLanguages, {code: req.language});
let isStaticPage = req.url.split('/')[1] === 'static'; // If url contains '/static/'
@@ -59,4 +59,4 @@ export default function locals (req, res, next) {
});
next();
}
};

View File

@@ -2,6 +2,6 @@ import {
NotFound,
} from '../../libs/api-v3/errors';
export default function (req, res, next) {
module.exports = function NotFoundMiddleware (req, res, next) {
next(new NotFound());
}
};

View File

@@ -1,7 +1,7 @@
export default function responseHandler (req, res, next) {
module.exports = function responseHandler (req, res, next) {
res.respond = function respond (status = 200, data = {}) {
res.status(status).json(data);
};
next();
}
};

View File

@@ -1,5 +1,5 @@
// TODO tests?
export default function setupBodyMiddleware (req, res, next) {
module.exports = function setupBodyMiddleware (req, res, next) {
req.body = req.body || {};
next();
}
};

View File

@@ -7,7 +7,7 @@ const MAX_AGE = IS_PROD ? 31536000000 : 0;
const PUBLIC_DIR = path.join(__dirname, '/../../../public');
const BUILD_DIR = path.join(__dirname, '/../../../build');
export default function staticMiddleware (expressApp) {
module.exports = function staticMiddleware (expressApp) {
// TODO move all static files to a single location (one for public and one for build)
expressApp.use(express.static(BUILD_DIR, { maxAge: MAX_AGE }));
expressApp.use('/common/dist', express.static(`${PUBLIC_DIR}/../../common/dist`, { maxAge: MAX_AGE }));
@@ -15,4 +15,4 @@ export default function staticMiddleware (expressApp) {
expressApp.use('/common/script/public', express.static(`${PUBLIC_DIR}/../../common/script/public`, { maxAge: MAX_AGE }));
expressApp.use('/common/img', express.static(`${PUBLIC_DIR}/../../common/img`, { maxAge: MAX_AGE }));
expressApp.use(express.static(PUBLIC_DIR));
}
};

View File

@@ -316,8 +316,8 @@ schema.methods.startQuest = async function startQuest (user) {
// send notifications in the background without blocking
User.find(
{ _id: { $in: nonUserQuestMembers } },
'party.quest items.quests auth.facebook auth.local preferences.emailNotifications pushDevices profile.name',
).exec().then(membersToNotify => {
'party.quest items.quests auth.facebook auth.local preferences.emailNotifications pushDevices profile.name'
).exec().then((membersToNotify) => {
let membersToEmail = _.filter(membersToNotify, (member) => {
// send push notifications and filter users that disabled emails
sendPushNotification(member, 'HabitRPG', `${shared.i18n.t('questStarted')}: ${quest.text()}`);

View File

@@ -167,4 +167,4 @@ server.listen(app.get('port'), () => {
return logger.info(`Express server listening on port ${app.get('port')}`);
});
export default server;
module.exports = server;