diff --git a/README.md b/README.md index 7c04dcc..f7f4582 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,33 @@ -# Sails.js Seed (Sample App) +# seed -A sample [Sails v1](https://sailsjs.com) application, generated with: +a [Sails v1](https://sailsjs.com) application generated with ``` sails new seed --caviar ``` +### Links + ++ [Get started](https://sailsjs.com/get-started) ++ [Sails framework documentation](https://sailsjs.com/documentation) ++ [Version notes / upgrading](https://sailsjs.com/documentation/upgrading) ++ [Deployment tips](https://sailsjs.com/documentation/concepts/deployment) ++ [Community support options](https://sailsjs.com/support) ++ [Professional / enterprise options](https://sailsjs.com/enterprise) -## Help -If you have questions or run into issues, check out our [recommended community support options](https://sailsjs.com/support). -> The Sails framework is actively maintained by The Sails Company, a full-service [web development studio in Austin, TX](https://sailsjs.com/studio), with the support of our [contributors](https://sailsjs.com/documentation/contributing). We created Sails in 2012 to assist us on Node.js projects, and to make it easier to build full-stack JavaScript applications. We hope it makes your life a little bit easier! +### Version info +This app was originally generated on Thu May 30 2019 10:19:52 GMT-0500 (CDT) using Sails v1.0.2. -## Version info + -This app was originally generated on Sun Mar 25 2018 14:03:40 GMT-0500 (CDT) using Sails v1.0.0-47. - +This project's boilerplate is based on an expanded seed app provided by the [Sails core team](https://sailsjs.com/about) to make it easier for you to build on top of ready-made features like authentication, enrollment, email verification, and billing. For more information, [drop us a line](https://sailsjs.com/support). -## Links - -+ [Get started](https://sailsjs.com/get-started) -+ [Sails framework documentation](https://sailsjs.com/documentation) -+ [Version notes / upgrading](https://sailsjs.com/documentation/upgrading) -+ [Deployment tips](https://sailsjs.com/documentation/concepts/deployment) -+ [Community support options](https://sailsjs.com/support) -+ [Professional / enterprise options](https://sailsjs.com/enterprise) - - -## Contributing -Please observe the guidelines and conventions laid out in the [Sails project contribution guide](https://sailsjs.com/documentation/contributing) when opening issues or submitting pull requests. - - -## License -The code in this repository, like the [Sails framework](https://sailsjs.com/whats-that), is free and open-source under the [MIT License](https://sailsjs.com/license). diff --git a/api/controllers/deliver-contact-form-message.js b/api/controllers/deliver-contact-form-message.js index 1510349..ca0f87a 100644 --- a/api/controllers/deliver-contact-form-message.js +++ b/api/controllers/deliver-contact-form-message.js @@ -62,7 +62,7 @@ your custom config -- usually in \`config/custom.js\`, \`config/staging.js\`, await sails.helpers.sendTemplateEmail.with({ to: sails.config.custom.internalEmailAddress, - subject: 'New Contact Form Message', + subject: 'New contact form message', template: 'internal/email-contact-form', layout: false, templateData: { diff --git a/api/controllers/entrance/login.js b/api/controllers/entrance/login.js index 934d901..d826d32 100644 --- a/api/controllers/entrance/login.js +++ b/api/controllers/entrance/login.js @@ -59,7 +59,7 @@ and exposed as \`req.me\`.)` responseType: 'unauthorized' // ^This uses the custom `unauthorized` response located in `api/responses/unauthorized.js`. // To customize the generic "unauthorized" response across this entire app, change that file - // (see http://sailsjs.com/anatomy/api/responses/unauthorized-js). + // (see api/responses/unauthorized). // // To customize the response for _only this_ action, replace `responseType` with // something else. For example, you might set `statusCode: 498` and change the diff --git a/api/controllers/view-homepage-or-redirect.js b/api/controllers/view-homepage-or-redirect.js index 1b01d48..25ebabb 100644 --- a/api/controllers/view-homepage-or-redirect.js +++ b/api/controllers/view-homepage-or-redirect.js @@ -12,7 +12,7 @@ module.exports = { success: { statusCode: 200, description: 'Requesting user is a guest, so show the public landing page.', - viewTemplatePath: 'pages/homepage.ejs' + viewTemplatePath: 'pages/homepage' }, redirect: { diff --git a/api/helpers/send-template-email.js b/api/helpers/send-template-email.js index ec44a00..d60e3a1 100644 --- a/api/helpers/send-template-email.js +++ b/api/helpers/send-template-email.js @@ -168,16 +168,16 @@ ${htmlEmailContents} if (!sails.config.custom.mailgunSecret || !sails.config.custom.mailgunDomain) { throw new Error(`Cannot deliver email to "${inputs.to}" because: - `+(()=>{ - let problems = []; - if (!sails.config.custom.mailgunSecret) { - problems.push(' • Mailgun secret is missing from this app\'s configuration (`sails.config.custom.mailgunSecret`)'); - } - if (!sails.config.custom.mailgunDomain) { - problems.push(' • Mailgun domain is missing from this app\'s configuration (`sails.config.custom.mailgunDomain`)'); - } - return problems.join('\n'); - })()+` + `+(()=>{ + let problems = []; + if (!sails.config.custom.mailgunSecret) { + problems.push(' • Mailgun secret is missing from this app\'s configuration (`sails.config.custom.mailgunSecret`)'); + } + if (!sails.config.custom.mailgunDomain) { + problems.push(' • Mailgun domain is missing from this app\'s configuration (`sails.config.custom.mailgunDomain`)'); + } + return problems.join('\n'); + })()+` To resolve these configuration issues, add the missing config variables to \`config/custom.js\`-- or in staging/production, set them up as system diff --git a/api/hooks/custom/index.js b/api/hooks/custom/index.js index d71408c..ee4123a 100644 --- a/api/hooks/custom/index.js +++ b/api/hooks/custom/index.js @@ -116,6 +116,8 @@ will be disabled and/or hidden in the UI. skipAssets: true, fn: async function(req, res, next){ + var url = require('url'); + // First, if this is a GET request (and thus potentially a view), // attach a couple of guaranteed locals. if (req.method === 'GET') { @@ -136,16 +138,21 @@ will be disabled and/or hidden in the UI. throw new Error('Cannot attach view local `me`, because this view local already exists! (Is it being attached somewhere else?)'); } res.locals.me = undefined; - }//fi - // Next, check if this is a GET request to the `webhooks.` or `click.` - // subdomains. If so, we'll automatically go ahead and redirect to the - // corresponding path under our base URL, which is environment-specific. + // Next, if we're running in our actual "production" or "staging" Sails + // environment, check if this is a GET request via some other subdomain, + // for example something like `webhooks.` or `click.`. If so, we'll + // automatically go ahead and redirect to the corresponding path under + // our base URL, which is environment-specific. // > Note that we DO NOT redirect virtual socket requests and we DO NOT // > redirect non-GET requests (because it can confuse some 3rd party // > platforms that send webhook requests.) - if (!req.isSocket && req.method === 'GET' && (req.subdomains[0] === 'webhooks' || req.subdomains[0] === 'links')) { + var configuredBaseSubdomain; + try { + configuredBaseSubdomain = url.parse(sails.config.custom.baseUrl).host.match(/^([^\.]+)\./)[1]; + } catch (unusedErr) { /*…*/} + if ((sails.config.environment === 'staging' || sails.config.environment === 'production') && !req.isSocket && req.method === 'GET' && req.subdomains[0] !== configuredBaseSubdomain) { sails.log.info('Redirecting GET request from `'+req.subdomains[0]+'.` subdomain...'); return res.redirect(sails.config.custom.baseUrl+req.url); }//• diff --git a/assets/.eslintrc b/assets/.eslintrc index c9724d1..7456a35 100644 --- a/assets/.eslintrc +++ b/assets/.eslintrc @@ -40,12 +40,12 @@ "parasails": true, "$": true, "_": true, + "bowser": true, "StripeCheckout": true, "Stripe": true, "Vue": true, "VueRouter": true, // "moment": true, - // "bowser": true // ...etc. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assets/dependencies/cloud.js b/assets/dependencies/cloud.js index 429780b..fe418ff 100644 --- a/assets/dependencies/cloud.js +++ b/assets/dependencies/cloud.js @@ -2,13 +2,19 @@ * cloud.js * (high-level AJAX library) * - * > This is now part of parasails. Originally branched from the original - * > Cloud SDK library at v1.0.1. (All future development of Cloud SDK will be - * > as part of parasails.) + * > This is now part of `parasails`. It was branched from the old "Cloud SDK" + * > library at its v1.0.1 -- but from that point on, its versioning has been + * > tied to the version of parasails it's bundled in. (All future development + * > of Cloud SDK will be as part of parasails.) * - * Copyright (c) 2015-2017, Mike McNeil, Scott Gress, Sails Co. (https://sailsjs.com/about) - * Copyright (c) 2014, Mike McNeil, Balderdash Design Co. (http://balderdash.co) + * Copyright (c) 2014-present, Mike McNeil * MIT License + * + * - https://twitter.com/mikermcneil + * - https://sailsjs.com/about + * - https://sailsjs.com/support + * - https://www.npmjs.com/package/parasails + * * --------------------------------------------------------------------------------------------- * ## Basic Usage * @@ -31,139 +37,24 @@ * ``` * --------------------------------------------------------------------------------------------- */ -(function(global, factory){ - var _; - var io; - var $; - var SAILS_LOCALS; - var location; - var File; - var FormData; - - // First, handle optional deps that are gleaned from the global state: - // > Note: Instead of throwing, we ignore invalid globals. - // > (Remember the bug w/ the File global that happened in Socket.io - // > back in ~2015!) - // ===================================================================== - if (global.location !== undefined) { - if (global.location && typeof global.location === 'object' && (global.location.constructor.name === 'Location' || global.location.constructor.toString() === '[object Location]')) { - location = global.location; - } - }//fi - if (global.File !== undefined) { - if (global.File && typeof global.File === 'function' && global.File.name === 'File') { - File = global.File; - } - }//fi - if (global.FormData !== undefined) { - if (global.FormData && typeof global.FormData === 'function' && global.FormData.name === 'FormData') { - FormData = global.FormData; - } - }//fi - - // Then, load the rest of the deps: - // ===================================================================== - - //˙°˚°·. - //‡CJS ˚°˚°·˛ - if (typeof exports === 'object' && typeof module !== 'undefined') { - var _require = require;// eslint-disable-line no-undef - var _module = module;// eslint-disable-line no-undef - // required deps: - if (typeof _ === 'undefined') { - try { - _ = _require('@sailshq/lodash'); - } catch (e) { if (e.code === 'MODULE_NOT_FOUND') {/* ok */} else { throw e; } } - }//fi - if (typeof _ === 'undefined') { - try { - _ = _require('lodash'); - } catch (e) { if (e.code === 'MODULE_NOT_FOUND') {/* ok */} else { throw e; } } - }//fi - - // optional deps: - try { $ = _require('jquery'); } catch (e) { if (e.code === 'MODULE_NOT_FOUND') {/* ok */} else { throw e; } } - try { - - io = _require('socket.io-client'); - var sailsIO = _require('sails.io.js'); - - // Instantiate the library (and start auto-connecting) - io = sailsIO(io); - - // Disable logging - io.sails.environment = 'production'; - - // Note that, if there is no location global, then after one tick, - // if `io.sails.url` has still not been set, weird errors will emerge. - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // FUTURE: figure out a way to provide a better err msg about this-- - // i.e. specifically the case where `.setup()` isn't called within one tick. - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } catch (err) { - if (err.code === 'MODULE_NOT_FOUND') { - // that's ok-- just make sure and unwind any vars that might have - // gotten partially set up, since we attempted to require more than - // one thing above (and e.g. the second `require()` might have failed) - io = undefined; - } else { - throw err; - } - } - - SAILS_LOCALS = undefined; - - // export: - _module.exports = factory(_, io, $, SAILS_LOCALS, location, File, FormData); - } - //˙°˚°· - //‡AMD ˚¸ - else if(typeof define === 'function' && define.amd) {// eslint-disable-line no-undef - throw new Error('Global `define()` function detected, but built-in AMD support in `cloud.js` is not currently recommended. To resolve this, modify `cloud.js`.'); - // var _define = define;// eslint-disable-line no-undef - // _define(['_', 'sails.io.js', '$', 'SAILS_LOCALS', 'location', 'file'], factory); - } - //˙°˚˙°· - //‡NUDE ˚°·˛ - else { - // required deps: - if (!global._) { throw new Error('`_` global does not exist on the page yet. (If you\'re using Sails, please check dependency loading order in pipeline.js and make sure the Lodash library is getting brought in before `cloud`.)'); } - _ = global._; - // optional deps: - if (global.io !== undefined) { - if (typeof global.io !== 'function') { - throw new Error('Could not access `io.socket`: The `io` global is invalid at the moment:' + global.io + '\n(If you\'re using Sails, please check dependency loading order in pipeline.js and make sure the sails.io.js library is getting brought in before `cloud`.)'); - } - else if (typeof global.io.socket === 'undefined') { - throw new Error('Could not access `io.socket`: `io` does not have a `socket` property. Make sure `sails.io.js` is being injected in a - <% /* Auto-injected