Skip to content

Commit

Permalink
eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
darioxlz committed Dec 19, 2018
1 parent 8873b6f commit 5e5ff1a
Show file tree
Hide file tree
Showing 41 changed files with 2,507 additions and 1,210 deletions.
17 changes: 17 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/frontend/vue.js
/frontend/app.js
*~
*#
.DS_STORE
.netbeans
nbproject
.idea
.node_history
dump.rdb

npm-debug.log
lib-cov
*.seed
*.log
*.out
*.pid
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "standard",
"globals": {
"localStorage": true,
"alert": true,
"sails": true,
"node": true,
"User": true,
"_": true,
"Vue": true
},
"rules": {
"quotes": [2, "double"],
"semi": [2, "always"],
"no-inner-declarations": 0,
"no-throw-literal": 0
}
}
93 changes: 0 additions & 93 deletions backend/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion backend/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* For more information see:
* https://sailsjs.com/anatomy/Gruntfile.js
*/
module.exports = function(grunt) {
module.exports = function (grunt) {

var loadGruntTasks = require('sails-hook-grunt/accessible/load-grunt-tasks');

Expand Down
2 changes: 0 additions & 2 deletions backend/api/controllers/TodosController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
*/

module.exports = {


};

30 changes: 9 additions & 21 deletions backend/api/controllers/account/logout.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
module.exports = {
friendlyName: "Logout",

description: "Log out of this app.",

friendlyName: 'Logout',


description: 'Log out of this app.',


extendedDescription:
`This action deletes the \`req.session.userId\` key from the session of the requesting user agent.
extendedDescription: `This action deletes the \`req.session.userId\` key from the session of the requesting user agent.
Actual garbage collection of session data depends on this app's session store, and
potentially also on the [TTL configuration](https://sailsjs.com/docs/reference/configuration/sails-config-session)
you provided for it.
Note that this action does not check to see whether or not the requesting user was
actually logged in. (If they weren't, then this action is just a no-op.)`,


exits: {

success: {
description: 'The requesting user agent has been successfully logged out.'
description: "The requesting user agent has been successfully logged out."
},

redirect: {
description: 'The requesting user agent looks to be a web browser.',
extendedDescription: 'After logging out from a web browser, the user is redirected away.',
responseType: 'redirect'
description: "The requesting user agent looks to be a web browser.",
extendedDescription:
"After logging out from a web browser, the user is redirected away.",
responseType: "redirect"
}

},


fn: async function () {

// Clear the `userId` property from this session.
delete this.req.session.userId;

// Then finish up, sending an appropriate response.
// > Under the covers, this persists the now-logged-out session back
// > to the underlying session store.
if (!this.req.wantsJSON) {
throw {redirect: '/login'};
throw { redirect: "/login" };
}

}


};
98 changes: 52 additions & 46 deletions backend/api/controllers/account/update-billing-card.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,85 @@
module.exports = {
friendlyName: "Update billing card",


friendlyName: 'Update billing card',


description: 'Update the credit card for the logged-in user.',

description: "Update the credit card for the logged-in user.",

inputs: {

stripeToken: {
type: 'string',
example: 'tok_199k3qEXw14QdSnRwmsK99MH',
description: 'The single-use Stripe Checkout token identifier representing the user\'s payment source (i.e. credit card.)',
extendedDescription: 'Omit this (or use "") to remove this user\'s payment source.',
type: "string",
example: "tok_199k3qEXw14QdSnRwmsK99MH",
description:
"The single-use Stripe Checkout token identifier representing the user's payment source (i.e. credit card.)",
extendedDescription:
"Omit this (or use \"\") to remove this user's payment source.",
whereToGet: {
description: 'This Stripe.js token is provided to the front-end (client-side) code after completing a Stripe Checkout or Stripe Elements flow.'
description:
"This Stripe.js token is provided to the front-end (client-side) code after completing a Stripe Checkout or Stripe Elements flow."
}
},

billingCardLast4: {
type: 'string',
example: '4242',
description: 'Omit if removing card info.',
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' }
type: "string",
example: "4242",
description: "Omit if removing card info.",
whereToGet: {
description:
"Credit card info is provided by Stripe after completing the checkout flow."
}
},

billingCardBrand: {
type: 'string',
example: 'visa',
description: 'Omit if removing card info.',
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' }
type: "string",
example: "visa",
description: "Omit if removing card info.",
whereToGet: {
description:
"Credit card info is provided by Stripe after completing the checkout flow."
}
},

billingCardExpMonth: {
type: 'string',
example: '08',
description: 'Omit if removing card info.',
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' }
type: "string",
example: "08",
description: "Omit if removing card info.",
whereToGet: {
description:
"Credit card info is provided by Stripe after completing the checkout flow."
}
},

billingCardExpYear: {
type: 'string',
example: '2023',
description: 'Omit if removing card info.',
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' }
},

type: "string",
example: "2023",
description: "Omit if removing card info.",
whereToGet: {
description:
"Credit card info is provided by Stripe after completing the checkout flow."
}
}
},


fn: async function (inputs) {

// Add, update, or remove the default payment source for the logged-in user's
// customer entry in Stripe.
var stripeCustomerId = await sails.helpers.stripe.saveBillingInfo.with({
stripeCustomerId: this.req.me.stripeCustomerId,
token: inputs.stripeToken || '',
}).timeout(5000).retry();
var stripeCustomerId = await sails.helpers.stripe.saveBillingInfo
.with({
stripeCustomerId: this.req.me.stripeCustomerId,
token: inputs.stripeToken || ""
})
.timeout(5000)
.retry();

// Update (or clear) the card info we have stored for this user in our database.
// > Remember, never store complete card numbers-- only the last 4 digits + expiration!
// > Storing (or even receiving) complete, unencrypted card numbers would require PCI
// > compliance in the U.S.
await User.updateOne({ id: this.req.me.id })
.set({
await User.updateOne({ id: this.req.me.id }).set({
stripeCustomerId,
hasBillingCard: inputs.stripeToken ? true : false,
billingCardBrand: inputs.stripeToken ? inputs.billingCardBrand : '',
billingCardLast4: inputs.stripeToken ? inputs.billingCardLast4 : '',
billingCardExpMonth: inputs.stripeToken ? inputs.billingCardExpMonth : '',
billingCardExpYear: inputs.stripeToken ? inputs.billingCardExpYear : ''
hasBillingCard: !!inputs.stripeToken,
billingCardBrand: inputs.stripeToken ? inputs.billingCardBrand : "",
billingCardLast4: inputs.stripeToken ? inputs.billingCardLast4 : "",
billingCardExpMonth: inputs.stripeToken ? inputs.billingCardExpMonth : "",
billingCardExpYear: inputs.stripeToken ? inputs.billingCardExpYear : ""
});

}


};
22 changes: 5 additions & 17 deletions backend/api/controllers/account/update-password.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
module.exports = {
friendlyName: "Update password",


friendlyName: 'Update password',


description: 'Update the password for the logged-in user.',

description: "Update the password for the logged-in user.",

inputs: {

password: {
description: 'The new, unencrypted password.',
example: 'abc123v2',
description: "The new, unencrypted password.",
example: "abc123v2",
required: true
}

},


fn: async function (inputs) {

// Hash the new password.
var hashed = await sails.helpers.passwords.hashPassword(inputs.password);

// Update the record for the logged-in user.
await User.updateOne({ id: this.req.me.id })
.set({
await User.updateOne({ id: this.req.me.id }).set({
password: hashed
});

}


};
Loading

0 comments on commit 5e5ff1a

Please sign in to comment.