mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix a few eslint rules
This commit is contained in:
@@ -7,7 +7,7 @@ var User = require('mongoose').model('User');
|
|||||||
var shared = require('../../../../common');
|
var shared = require('../../../../common');
|
||||||
var payments = require('./index');
|
var payments = require('./index');
|
||||||
var cc = require('coupon-code');
|
var cc = require('coupon-code');
|
||||||
var isProd = nconf.get("NODE_ENV") === 'production';
|
var isProd = nconf.get('NODE_ENV') === 'production';
|
||||||
|
|
||||||
var amzPayment = amazonPayments.connect({
|
var amzPayment = amazonPayments.connect({
|
||||||
environment: amazonPayments.Environment[isProd ? 'Production' : 'Sandbox'],
|
environment: amazonPayments.Environment[isProd ? 'Production' : 'Sandbox'],
|
||||||
@@ -122,7 +122,7 @@ exports.checkout = function(req, res, next){
|
|||||||
|
|
||||||
executePayment: function(cb){
|
executePayment: function(cb){
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(cb2){ User.findById(gift ? gift.uuid : undefined, cb2) },
|
function(cb2){ User.findById(gift ? gift.uuid : undefined, cb2); },
|
||||||
function(member, cb2){
|
function(member, cb2){
|
||||||
var data = {user:user, paymentMethod:'Amazon Payments'};
|
var data = {user:user, paymentMethod:'Amazon Payments'};
|
||||||
var method = 'buyGems';
|
var method = 'buyGems';
|
||||||
@@ -151,7 +151,7 @@ exports.subscribe = function(req, res, next){
|
|||||||
return res.json(400, {err: 'Billing Agreement Id not supplied.'});
|
return res.json(400, {err: 'Billing Agreement Id not supplied.'});
|
||||||
}
|
}
|
||||||
|
|
||||||
var billingAgreementId = req.body.billingAgreementId
|
var billingAgreementId = req.body.billingAgreementId;
|
||||||
var sub = req.body.subscription ? shared.content.subscriptionBlocks[req.body.subscription] : false;
|
var sub = req.body.subscription ? shared.content.subscriptionBlocks[req.body.subscription] : false;
|
||||||
var coupon = req.body.coupon;
|
var coupon = req.body.coupon;
|
||||||
var user = res.locals.user;
|
var user = res.locals.user;
|
||||||
@@ -167,7 +167,7 @@ exports.subscribe = function(req, res, next){
|
|||||||
mongoose.model('Coupon').findOne({_id:cc.validate(coupon), event:sub.key}, function(err, coupon){
|
mongoose.model('Coupon').findOne({_id:cc.validate(coupon), event:sub.key}, function(err, coupon){
|
||||||
if(err) return cb(err);
|
if(err) return cb(err);
|
||||||
if(!coupon) return cb(new Error('Coupon code not found.'));
|
if(!coupon) return cb(new Error('Coupon code not found.'));
|
||||||
cb()
|
cb();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ exports.subscribe = function(req, res, next){
|
|||||||
exports.subscribeCancel = function(req, res, next){
|
exports.subscribeCancel = function(req, res, next){
|
||||||
var user = res.locals.user;
|
var user = res.locals.user;
|
||||||
if (!user.purchased.plan.customerId)
|
if (!user.purchased.plan.customerId)
|
||||||
return res.json(401, {err: "User does not have a plan subscription"});
|
return res.json(401, {err: 'User does not have a plan subscription'});
|
||||||
|
|
||||||
var billingAgreementId = user.purchased.plan.customerId;
|
var billingAgreementId = user.purchased.plan.customerId;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var nconf = require('nconf');
|
|||||||
var inAppPurchase = require('in-app-purchase');
|
var inAppPurchase = require('in-app-purchase');
|
||||||
inAppPurchase.config({
|
inAppPurchase.config({
|
||||||
// this is the path to the directory containing iap-sanbox/iap-live files
|
// this is the path to the directory containing iap-sanbox/iap-live files
|
||||||
googlePublicKeyPath: nconf.get("IAP_GOOGLE_KEYDIR")
|
googlePublicKeyPath: nconf.get('IAP_GOOGLE_KEYDIR')
|
||||||
});
|
});
|
||||||
|
|
||||||
// Validation ERROR Codes
|
// Validation ERROR Codes
|
||||||
@@ -101,7 +101,7 @@ exports.iosVerify = function(req, res, next) {
|
|||||||
if (iap.isValidated(appleRes)) {
|
if (iap.isValidated(appleRes)) {
|
||||||
var purchaseDataList = iap.getPurchaseData(appleRes);
|
var purchaseDataList = iap.getPurchaseData(appleRes);
|
||||||
if (purchaseDataList.length > 0) {
|
if (purchaseDataList.length > 0) {
|
||||||
if (purchaseDataList[0].productId === "com.habitrpg.ios.Habitica.20gems") {
|
if (purchaseDataList[0].productId === 'com.habitrpg.ios.Habitica.20gems') {
|
||||||
//Correct receipt
|
//Correct receipt
|
||||||
payments.buyGems({user:user, paymentMethod:'IAP AppleStore'});
|
payments.buyGems({user:user, paymentMethod:'IAP AppleStore'});
|
||||||
var resObj = {
|
var resObj = {
|
||||||
@@ -117,7 +117,7 @@ exports.iosVerify = function(req, res, next) {
|
|||||||
ok: false,
|
ok: false,
|
||||||
data: {
|
data: {
|
||||||
code: INVALID_PAYLOAD,
|
code: INVALID_PAYLOAD,
|
||||||
message: "Incorrect receipt content"
|
message: 'Incorrect receipt content'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return res.json(resObj);
|
return res.json(resObj);
|
||||||
@@ -127,7 +127,7 @@ exports.iosVerify = function(req, res, next) {
|
|||||||
ok: false,
|
ok: false,
|
||||||
data: {
|
data: {
|
||||||
code: INVALID_PAYLOAD,
|
code: INVALID_PAYLOAD,
|
||||||
message: "Invalid receipt"
|
message: 'Invalid receipt'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var nconf = require('nconf');
|
var nconf = require('nconf');
|
||||||
var stripe = require("stripe")(nconf.get('STRIPE_API_KEY'));
|
var stripe = require('stripe')(nconf.get('STRIPE_API_KEY'));
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var payments = require('./index');
|
var payments = require('./index');
|
||||||
var User = require('mongoose').model('User');
|
var User = require('mongoose').model('User');
|
||||||
@@ -38,10 +38,10 @@ exports.checkout = function(req, res, next) {
|
|||||||
], cb);
|
], cb);
|
||||||
} else {
|
} else {
|
||||||
stripe.charges.create({
|
stripe.charges.create({
|
||||||
amount: !gift ? "500" //"500" = $5
|
amount: !gift ? '500' //"500" = $5
|
||||||
: gift.type=='subscription' ? ""+shared.content.subscriptionBlocks[gift.subscription.key].price*100
|
: gift.type=='subscription' ? ''+shared.content.subscriptionBlocks[gift.subscription.key].price*100
|
||||||
: ""+gift.gems.amount/4*100,
|
: ''+gift.gems.amount/4*100,
|
||||||
currency: "usd",
|
currency: 'usd',
|
||||||
card: token
|
card: token
|
||||||
}, cb);
|
}, cb);
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ exports.checkout = function(req, res, next) {
|
|||||||
function(response, cb) {
|
function(response, cb) {
|
||||||
if (sub) return payments.createSubscription({user:user, customerId:response.id, paymentMethod:'Stripe', sub:sub}, cb);
|
if (sub) return payments.createSubscription({user:user, customerId:response.id, paymentMethod:'Stripe', sub:sub}, cb);
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(cb2){ User.findById(gift ? gift.uuid : undefined, cb2) },
|
function(cb2){ User.findById(gift ? gift.uuid : undefined, cb2); },
|
||||||
function(member, cb2){
|
function(member, cb2){
|
||||||
var data = {user:user, customerId:response.id, paymentMethod:'Stripe', gift:gift};
|
var data = {user:user, customerId:response.id, paymentMethod:'Stripe', gift:gift};
|
||||||
var method = 'buyGems';
|
var method = 'buyGems';
|
||||||
@@ -72,7 +72,7 @@ exports.checkout = function(req, res, next) {
|
|||||||
exports.subscribeCancel = function(req, res, next) {
|
exports.subscribeCancel = function(req, res, next) {
|
||||||
var user = res.locals.user;
|
var user = res.locals.user;
|
||||||
if (!user.purchased.plan.customerId)
|
if (!user.purchased.plan.customerId)
|
||||||
return res.json(401, {err: "User does not have a plan subscription"});
|
return res.json(401, {err: 'User does not have a plan subscription'});
|
||||||
|
|
||||||
async.auto({
|
async.auto({
|
||||||
get_cus: function(cb){
|
get_cus: function(cb){
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ module.exports = function(server,mongoose) {
|
|||||||
apdexBad = score < .75 || score == 1,
|
apdexBad = score < .75 || score == 1,
|
||||||
memory = os.freemem() / os.totalmem(),
|
memory = os.freemem() / os.totalmem(),
|
||||||
memoryHigh = memory < 0.1;
|
memoryHigh = memory < 0.1;
|
||||||
if (/*apdexBad || */memoryHigh) throw "[Memory Leak] Apdex="+score+" Memory="+parseFloat(memory).toFixed(3)+" Time="+moment().format();
|
if (/*apdexBad || */memoryHigh) throw '[Memory Leak] Apdex='+score+' Memory='+parseFloat(memory).toFixed(3)+' Time='+moment().format();
|
||||||
});
|
});
|
||||||
}, mins*60*1000);
|
}, mins*60*1000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var nconf = require('nconf');
|
var nconf = require('nconf');
|
||||||
var IS_PROD = nconf.get('NODE_ENV') === 'production';
|
var IS_PROD = nconf.get('NODE_ENV') === 'production';
|
||||||
var ignoreRedirect = nconf.get('IGNORE_REDIRECT');
|
var ignoreRedirect = nconf.get('IGNORE_REDIRECT');
|
||||||
var BASE_URL = nconf.get("BASE_URL");
|
var BASE_URL = nconf.get('BASE_URL');
|
||||||
|
|
||||||
function isHTTP(req) {
|
function isHTTP(req) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ var i18n = require('../i18n');
|
|||||||
// -------- App --------
|
// -------- App --------
|
||||||
router.get('/', i18n.getUserLanguage, locals, function(req, res) {
|
router.get('/', i18n.getUserLanguage, locals, function(req, res) {
|
||||||
if (!req.headers['x-api-user'] && !req.headers['x-api-key'] && !(req.session && req.session.userId))
|
if (!req.headers['x-api-user'] && !req.headers['x-api-key'] && !(req.session && req.session.userId))
|
||||||
return res.redirect('/static/front')
|
return res.redirect('/static/front');
|
||||||
|
|
||||||
return res.render('index', {
|
return res.render('index', {
|
||||||
title: 'Habitica | Your Life The Role Playing Game',
|
title: 'Habitica | Your Life The Role Playing Game',
|
||||||
@@ -29,7 +29,7 @@ _.each(pages, function(name){
|
|||||||
marked: require('marked')
|
marked: require('marked')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
// --------- Redirects --------
|
// --------- Redirects --------
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ router.get('/paypal/subscribe/success', i18n.getUserLanguage, payments.paypalSub
|
|||||||
router.get('/paypal/subscribe/cancel', auth.authWithUrl, i18n.getUserLanguage, payments.paypalSubscribeCancel);
|
router.get('/paypal/subscribe/cancel', auth.authWithUrl, i18n.getUserLanguage, payments.paypalSubscribeCancel);
|
||||||
router.post('/paypal/ipn', i18n.getUserLanguage, payments.paypalIPN); // misc ipn handling
|
router.post('/paypal/ipn', i18n.getUserLanguage, payments.paypalIPN); // misc ipn handling
|
||||||
|
|
||||||
router.post("/stripe/checkout", auth.auth, i18n.getUserLanguage, payments.stripeCheckout);
|
router.post('/stripe/checkout', auth.auth, i18n.getUserLanguage, payments.stripeCheckout);
|
||||||
router.post("/stripe/subscribe/edit", auth.auth, i18n.getUserLanguage, payments.stripeSubscribeEdit)
|
router.post('/stripe/subscribe/edit', auth.auth, i18n.getUserLanguage, payments.stripeSubscribeEdit);
|
||||||
//router.get("/stripe/subscribe", auth.authWithUrl, i18n.getUserLanguage, payments.stripeSubscribe); // checkout route is used (above) with ?plan= instead
|
//router.get('/stripe/subscribe', auth.authWithUrl, i18n.getUserLanguage, payments.stripeSubscribe); // checkout route is used (above) with ?plan= instead
|
||||||
router.get("/stripe/subscribe/cancel", auth.authWithUrl, i18n.getUserLanguage, payments.stripeSubscribeCancel);
|
router.get('/stripe/subscribe/cancel', auth.authWithUrl, i18n.getUserLanguage, payments.stripeSubscribeCancel);
|
||||||
|
|
||||||
router.post('/amazon/verifyAccessToken', auth.auth, i18n.getUserLanguage, payments.amazonVerifyAccessToken);
|
router.post('/amazon/verifyAccessToken', auth.auth, i18n.getUserLanguage, payments.amazonVerifyAccessToken);
|
||||||
router.post('/amazon/createOrderReferenceId', auth.auth, i18n.getUserLanguage, payments.amazonCreateOrderReferenceId);
|
router.post('/amazon/createOrderReferenceId', auth.auth, i18n.getUserLanguage, payments.amazonCreateOrderReferenceId);
|
||||||
@@ -23,9 +23,9 @@ router.post('/amazon/checkout', auth.auth, i18n.getUserLanguage, payments.amazon
|
|||||||
router.post('/amazon/subscribe', auth.auth, i18n.getUserLanguage, payments.amazonSubscribe);
|
router.post('/amazon/subscribe', auth.auth, i18n.getUserLanguage, payments.amazonSubscribe);
|
||||||
router.get('/amazon/subscribe/cancel', auth.authWithUrl, i18n.getUserLanguage, payments.amazonSubscribeCancel);
|
router.get('/amazon/subscribe/cancel', auth.authWithUrl, i18n.getUserLanguage, payments.amazonSubscribeCancel);
|
||||||
|
|
||||||
router.post("/iap/android/verify", auth.authWithUrl, /*i18n.getUserLanguage, */payments.iapAndroidVerify);
|
router.post('/iap/android/verify', auth.authWithUrl, /*i18n.getUserLanguage, */payments.iapAndroidVerify);
|
||||||
router.post("/iap/ios/verify", auth.auth, /*i18n.getUserLanguage, */ payments.iapIosVerify);
|
router.post('/iap/ios/verify', auth.auth, /*i18n.getUserLanguage, */ payments.iapIosVerify);
|
||||||
|
|
||||||
router.get("/api/v2/coupons/valid-discount/:code", /*auth.authWithUrl, i18n.getUserLanguage, */ payments.validCoupon);
|
router.get('/api/v2/coupons/valid-discount/:code', /*auth.authWithUrl, i18n.getUserLanguage, */ payments.validCoupon);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
Reference in New Issue
Block a user