Fix linting
This commit is contained in:
parent
553ba9db9a
commit
bb5189c9ed
35 changed files with 157 additions and 866 deletions
|
@ -47,8 +47,8 @@ export async function list(ctx) {
|
|||
processed: true,
|
||||
},
|
||||
order: [
|
||||
['createdAt', 'DESC'],
|
||||
],
|
||||
['createdAt', 'DESC'],
|
||||
],
|
||||
offset,
|
||||
limit,
|
||||
});
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
import path from 'path';
|
||||
import views from 'co-views';
|
||||
const render = views(path.join(__dirname, '/../views'), { default: 'ejs' });
|
||||
import Stripe from 'stripe';
|
||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
||||
import sendgridInit from 'sendgrid';
|
||||
const sendgrid = sendgridInit(process.env.SENDGRID_KEY);
|
||||
|
||||
import models from '../../models';
|
||||
|
||||
const render = views(path.join(__dirname, '/../views'), { default: 'ejs' });
|
||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
||||
const sendgrid = sendgridInit(process.env.SENDGRID_KEY);
|
||||
|
||||
const from = process.env.EMAIL_FROM;
|
||||
const fromname = process.env.EMAIL_NAME;
|
||||
|
||||
export async function create(ctx) {
|
||||
const stripeToken = ctx.request.body.stripeToken;
|
||||
const { stripeToken } = ctx.request.body;
|
||||
|
||||
const ip = ctx.request.headers['x-forwarded-for'] || ctx.req.connection.remoteAddress;
|
||||
|
||||
|
@ -74,7 +75,7 @@ export async function cancel(ctx) {
|
|||
await stripe.customers.cancelSubscription(
|
||||
transaction.data.id,
|
||||
transaction.data.subscription.id,
|
||||
{ at_period_end: false }
|
||||
{ at_period_end: false },
|
||||
);
|
||||
|
||||
user.plan = 'Free';
|
||||
|
|
|
@ -2,9 +2,10 @@ import uuid from 'node-uuid';
|
|||
import redis from 'redis';
|
||||
import co from 'co';
|
||||
import passwords from 'passwords';
|
||||
import debugname from 'debug';
|
||||
|
||||
import models from '../../models';
|
||||
|
||||
import debugname from 'debug';
|
||||
const debug = debugname('hostr-api:user');
|
||||
|
||||
const redisUrl = process.env.REDIS_URL;
|
||||
|
@ -26,31 +27,37 @@ export async function transaction(ctx) {
|
|||
},
|
||||
});
|
||||
|
||||
ctx.body = transactions.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
amount: item.amount / 100,
|
||||
date: item.date,
|
||||
description: item.description,
|
||||
type: 'direct',
|
||||
};
|
||||
});
|
||||
ctx.body = transactions.map(item => ({
|
||||
id: item.id,
|
||||
amount: item.amount / 100,
|
||||
date: item.date,
|
||||
description: item.description,
|
||||
type: 'direct',
|
||||
}));
|
||||
}
|
||||
|
||||
export async function settings(ctx) {
|
||||
ctx.assert(ctx.request.body, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}');
|
||||
ctx.assert(ctx.request.body.current_password, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}');
|
||||
ctx.assert(
|
||||
ctx.request.body, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}',
|
||||
);
|
||||
ctx.assert(
|
||||
ctx.request.body.current_password, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}',
|
||||
);
|
||||
const user = await models.user.findById(ctx.user.id);
|
||||
ctx.assert(await passwords.match(ctx.request.body.current_password, user.password), 400,
|
||||
'{"error": {"message": "Incorrect password", "code": 606}}');
|
||||
ctx.assert(
|
||||
await passwords.match(ctx.request.body.current_password, user.password), 400,
|
||||
'{"error": {"message": "Incorrect password", "code": 606}}',
|
||||
);
|
||||
if (ctx.request.body.email && ctx.request.body.email !== user.email) {
|
||||
user.email = ctx.request.body.email;
|
||||
}
|
||||
if (ctx.request.body.new_password) {
|
||||
ctx.assert(ctx.request.body.new_password.length >= 7, 400,
|
||||
'{"error": {"message": "Password must be 7 or more characters long.", "code": 606}}');
|
||||
ctx.assert(
|
||||
ctx.request.body.new_password.length >= 7, 400,
|
||||
'{"error": {"message": "Password must be 7 or more characters long.", "code": 606}}',
|
||||
);
|
||||
user.password = await passwords.hash(ctx.request.body.new_password);
|
||||
}
|
||||
await user.save();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue