Initial project structure with sails.js

This commit is contained in:
2023-11-21 21:57:32 -05:00
commit 523978e520
197 changed files with 76740 additions and 0 deletions

41
config/blueprints.js Normal file
View File

@ -0,0 +1,41 @@
/**
* Blueprint API Configuration
* (sails.config.blueprints)
*
* For background on the blueprint API in Sails, check out:
* https://sailsjs.com/docs/reference/blueprint-api
*
* For details and more available options, see:
* https://sailsjs.com/config/blueprints
*/
module.exports.blueprints = {
/***************************************************************************
* *
* Automatically expose implicit routes for every action in your app? *
* *
***************************************************************************/
// actions: false,
/***************************************************************************
* *
* Automatically expose RESTful routes for your models? *
* *
***************************************************************************/
rest: false,
/***************************************************************************
* *
* Automatically expose CRUD "shortcut" routes to GET requests? *
* (These are enabled by default in development only.) *
* *
***************************************************************************/
shortcuts: false,
};

79
config/bootstrap.js vendored Normal file
View File

@ -0,0 +1,79 @@
/**
* Seed Function
* (sails.config.bootstrap)
*
* A function that runs just before your Sails app gets lifted.
* > Need more flexibility? You can also create a hook.
*
* For more information on seeding your app with fake data, check out:
* https://sailsjs.com/config/bootstrap
*/
module.exports.bootstrap = async function() {
// Import dependencies
var path = require('path');
// This bootstrap version indicates what version of fake data we're dealing with here.
var HARD_CODED_DATA_VERSION = 0;
// This path indicates where to store/look for the JSON file that tracks the "last run bootstrap info"
// locally on this development computer (if we happen to be on a development computer).
var bootstrapLastRunInfoPath = path.resolve(sails.config.appPath, '.tmp/bootstrap-version.json');
// Whether or not to continue doing the stuff in this file (i.e. wiping and regenerating data)
// depends on some factors:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If the hard-coded data version has been incremented, or we're being forced
// (i.e. `--drop` or `--environment=test` was set), then run the meat of this
// bootstrap script to wipe all existing data and rebuild hard-coded data.
if (sails.config.models.migrate !== 'drop' && sails.config.environment !== 'test') {
// If this is _actually_ a production environment (real or simulated), or we have
// `migrate: safe` enabled, then prevent accidentally removing all data!
if (process.env.NODE_ENV==='production' || sails.config.models.migrate === 'safe') {
sails.log('Since we are running with migrate: \'safe\' and/or NODE_ENV=production (in the "'+sails.config.environment+'" Sails environment, to be precise), skipping the rest of the bootstrap to avoid data loss...');
return;
}//•
// Compare bootstrap version from code base to the version that was last run
var lastRunBootstrapInfo = await sails.helpers.fs.readJson(bootstrapLastRunInfoPath)
.tolerate('doesNotExist');// (it's ok if the file doesn't exist yet-- just keep going.)
if (lastRunBootstrapInfo && lastRunBootstrapInfo.lastRunVersion === HARD_CODED_DATA_VERSION) {
sails.log('Skipping v'+HARD_CODED_DATA_VERSION+' bootstrap script... (because it\'s already been run)');
sails.log('(last run on this computer: @ '+(new Date(lastRunBootstrapInfo.lastRunAt))+')');
return;
}//•
sails.log('Running v'+HARD_CODED_DATA_VERSION+' bootstrap script... ('+(lastRunBootstrapInfo ? 'before this, the last time the bootstrap ran on this computer was for v'+lastRunBootstrapInfo.lastRunVersion+' @ '+(new Date(lastRunBootstrapInfo.lastRunAt)) : 'looks like this is the first time the bootstrap has run on this computer')+')');
}
else {
sails.log('Running bootstrap script because it was forced... (either `--drop` or `--environment=test` was used)');
}
// Since the hard-coded data version has been incremented, and we're running in
// a "throwaway data" environment, delete all records from all models.
for (let identity in sails.models) {
await sails.models[identity].destroy({});
}//∞
// By convention, this is a good place to set up fake data during development.
await User.createEach([
{ emailAddress: 'admin@example.com', fullName: 'Ryan Dahl', isSuperAdmin: true, password: await sails.helpers.passwords.hashPassword('abc123') },
]);
// Save new bootstrap version
await sails.helpers.fs.writeJson.with({
destination: bootstrapLastRunInfoPath,
json: {
lastRunVersion: HARD_CODED_DATA_VERSION,
lastRunAt: Date.now()
},
force: true
})
.tolerate((err)=>{
sails.log.warn('For some reason, could not write bootstrap version .json file. This could be a result of a problem with your configured paths, or, if you are in production, a limitation of your hosting provider related to `pwd`. As a workaround, try updating app.js to explicitly pass in `appPath: __dirname` instead of relying on `chdir`. Current sails.config.appPath: `'+sails.config.appPath+'`. Full error details: '+err.stack+'\n\n(Proceeding anyway this time...)');
});
};

105
config/custom.js Normal file
View File

@ -0,0 +1,105 @@
/**
* Custom configuration
* (sails.config.custom)
*
* One-off settings specific to your application.
*
* For more information on custom configuration, visit:
* https://sailsjs.com/config/custom
*/
module.exports.custom = {
/**************************************************************************
* *
* The base URL to use during development. *
* *
* • No trailing slash at the end *
* • `http://` or `https://` at the beginning. *
* *
* > This is for use in custom logic that builds URLs. *
* > It is particularly handy for building dynamic links in emails, *
* > but it can also be used for user-uploaded images, webhooks, etc. *
* *
**************************************************************************/
baseUrl: 'http://localhost:1337',
/**************************************************************************
* *
* Display dates for your app *
* *
* > This is here to make it easier to change out the copyright date *
* > that is displayed all over the app when it's first generated. *
* *
**************************************************************************/
platformCopyrightYear: '2021',
/**************************************************************************
* *
* The TTL (time-to-live) for various sorts of tokens before they expire. *
* *
**************************************************************************/
passwordResetTokenTTL: 24*60*60*1000,// 24 hours
emailProofTokenTTL: 24*60*60*1000,// 24 hours
/**************************************************************************
* *
* The extended length that browsers should retain the session cookie *
* if "Remember Me" was checked while logging in. *
* *
**************************************************************************/
rememberMeCookieMaxAge: 30*24*60*60*1000, // 30 days
/**************************************************************************
* *
* Automated email configuration *
* *
* Sandbox Sendgrid credentials for use during development, as well as any *
* other default settings related to "how" and "where" automated emails *
* are sent. *
* *
* (https://app.sendgrid.com/settings/api_keys) *
* *
**************************************************************************/
// sendgridSecret: 'SG.fake.3e0Bn0qSQVnwb1E4qNPz9JZP5vLZYqjh7sn8S93oSHU',
//--------------------------------------------------------------------------
// /\ Configure this to enable support for automated emails.
// || (Important for password recovery, verification, contact form, etc.)
//--------------------------------------------------------------------------
// The sender that all outgoing emails will appear to come from.
fromEmailAddress: 'noreply@example.com',
fromName: 'The NEW_APP_NAME Team',
// Email address for receiving support messages & other correspondences.
// > If you're using the default privacy policy, this will be referenced
// > as the contact email of your "data protection officer" for the purpose
// > of compliance with regulations such as GDPR.
internalEmailAddress: 'support+development@example.com',
// Whether to require proof of email address ownership any time a new user
// signs up, or when an existing user attempts to change their email address.
verifyEmailAddresses: false,
/**************************************************************************
* *
* Billing & payments configuration *
* *
* (https://dashboard.stripe.com/account/apikeys) *
* *
**************************************************************************/
// stripePublishableKey: 'pk_test_Zzd814nldl91104qor5911gjald',
// stripeSecret: 'sk_test_Zzd814nldl91104qor5911gjald',
//--------------------------------------------------------------------------
// /\ Configure these to enable support for billing features.
// || (Or if you don't need billing, feel free to remove them.)
//--------------------------------------------------------------------------
/***************************************************************************
* *
* Any other custom config this Sails app should use during development. *
* *
***************************************************************************/
// …
};

57
config/datastores.js Normal file
View File

@ -0,0 +1,57 @@
/**
* Datastores
* (sails.config.datastores)
*
* A set of datastore configurations which tell Sails where to fetch or save
* data when you execute built-in model methods like `.find()` and `.create()`.
*
* > This file is mainly useful for configuring your development database,
* > as well as any additional one-off databases used by individual models.
* > Ready to go live? Head towards `config/env/production.js`.
*
* For more information on configuring datastores, check out:
* https://sailsjs.com/config/datastores
*/
module.exports.datastores = {
/***************************************************************************
* *
* Your app's default datastore. *
* *
* Sails apps read and write to local disk by default, using a built-in *
* database adapter called `sails-disk`. This feature is purely for *
* convenience during development; since `sails-disk` is not designed for *
* use in a production environment. *
* *
* To use a different db _in development_, follow the directions below. *
* Otherwise, just leave the default datastore as-is, with no `adapter`. *
* *
* (For production configuration, see `config/env/production.js`.) *
* *
***************************************************************************/
default: {
/***************************************************************************
* *
* Want to use a different database during development? *
* *
* 1. Choose an adapter: *
* https://sailsjs.com/plugins/databases *
* *
* 2. Install it as a dependency of your Sails app. *
* (For example: npm install sails-mysql --save) *
* *
* 3. Then pass it in, along with a connection URL. *
* (See https://sailsjs.com/config/datastores for help.) *
* *
***************************************************************************/
// adapter: 'sails-mysql',
// url: 'mysql://user:password@host:port/database',
},
};

412
config/env/production.js vendored Normal file
View File

@ -0,0 +1,412 @@
/**
* Production environment settings
* (sails.config.*)
*
* What you see below is a quick outline of the built-in settings you need
* to configure your Sails app for production. The configuration in this file
* is only used in your production environment, i.e. when you lift your app using:
*
* ```
* NODE_ENV=production node app
* ```
*
* > If you're using git as a version control solution for your Sails app,
* > this file WILL BE COMMITTED to your repository by default, unless you add
* > it to your .gitignore file. If your repository will be publicly viewable,
* > don't add private/sensitive data (like API secrets / db passwords) to this file!
*
* For more best practices and tips, see:
* https://sailsjs.com/docs/concepts/deployment
*/
module.exports = {
/**************************************************************************
* *
* Tell Sails what database(s) it should use in production. *
* *
* (https://sailsjs.com/config/datastores) *
* *
**************************************************************************/
datastores: {
/***************************************************************************
* *
* Configure your default production database. *
* *
* 1. Choose an adapter: *
* https://sailsjs.com/plugins/databases *
* *
* 2. Install it as a dependency of your Sails app. *
* (For example: npm install sails-mysql --save) *
* *
* 3. Then set it here (`adapter`), along with a connection URL (`url`) *
* and any other, adapter-specific customizations. *
* (See https://sailsjs.com/config/datastores for help.) *
* *
***************************************************************************/
default: {
// adapter: 'sails-mysql',
// url: 'mysql://user:password@host:port/database',
//--------------------------------------------------------------------------
// /\ To avoid checking it in to version control, you might opt to set
// || sensitive credentials like `url` using an environment variable.
//
// For example:
// ```
// sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db
// ```
//--------------------------------------------------------------------------
/****************************************************************************
* *
* More adapter-specific options *
* *
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
* > extra `ssl` object with a `rejectUnauthorized` option must be provided. *
* *
* More info: *
* https://sailsjs.com/config/datastores *
* *
****************************************************************************/
// ssl: { rejectUnauthorized: true },
},
},
models: {
/***************************************************************************
* *
* To help avoid accidents, Sails automatically sets the automigration *
* strategy to "safe" when your app lifts in production mode. *
* (This is just here as a reminder.) *
* *
* More info: *
* https://sailsjs.com/docs/concepts/models-and-orm/model-settings#?migrate *
* *
***************************************************************************/
migrate: 'safe',
/***************************************************************************
* *
* If, in production, this app has access to physical-layer CASCADE *
* constraints (e.g. PostgreSQL or MySQL), then set those up in the *
* database and uncomment this to disable Waterline's `cascadeOnDestroy` *
* polyfill. (Otherwise, if you are using a databse like Mongo, you might *
* choose to keep this enabled.) *
* *
***************************************************************************/
// cascadeOnDestroy: false,
},
/**************************************************************************
* *
* Always disable "shortcut" blueprint routes. *
* *
* > You'll also want to disable any other blueprint routes if you are not *
* > actually using them (e.g. "actions" and "rest") -- but you can do *
* > that in `config/blueprints.js`, since you'll want to disable them in *
* > all environments (not just in production.) *
* *
***************************************************************************/
blueprints: {
shortcuts: false,
},
/***************************************************************************
* *
* Configure your security settings for production. *
* *
* IMPORTANT: *
* If web browsers will be communicating with your app, be sure that *
* you have CSRF protection enabled. To do that, set `csrf: true` over *
* in the `config/security.js` file (not here), so that CSRF app can be *
* tested with CSRF protection turned on in development mode too. *
* *
***************************************************************************/
security: {
/***************************************************************************
* *
* If this app has CORS enabled (see `config/security.js`) with the *
* `allowCredentials` setting enabled, then you should uncomment the *
* `allowOrigins` whitelist below. This sets which "origins" are allowed *
* to send cross-domain (CORS) requests to your Sails app. *
* *
* > Replace "https://example.com" with the URL of your production server. *
* > Be sure to use the right protocol! ("http://" vs. "https://") *
* *
***************************************************************************/
cors: {
// allowOrigins: [
// 'https://example.com',
// ]
},
},
/***************************************************************************
* *
* Configure how your app handles sessions in production. *
* *
* (https://sailsjs.com/config/session) *
* *
* > If you have disabled the "session" hook, then you can safely remove *
* > this section from your `config/env/production.js` file. *
* *
***************************************************************************/
session: {
/***************************************************************************
* *
* Production session store configuration. *
* *
* Uncomment the following lines to finish setting up a package called *
* "@sailshq/connect-redis" that will use Redis to handle session data. *
* This makes your app more scalable by allowing you to share sessions *
* across a cluster of multiple Sails/Node.js servers and/or processes. *
* (See http://bit.ly/redis-session-config for more info.) *
* *
* > While @sailshq/connect-redis is a popular choice for Sails apps, many *
* > other compatible packages (like "connect-mongo") are available on NPM. *
* > (For a full list, see https://sailsjs.com/plugins/sessions) *
* *
***************************************************************************/
// adapter: '@sailshq/connect-redis',
// url: 'redis://user:password@localhost:6379/databasenumber',
//--------------------------------------------------------------------------
// /\ OR, to avoid checking it in to version control, you might opt to
// || set sensitive credentials like this using an environment variable.
//
// For example:
// ```
// sails_session__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/0
// ```
//
//--------------------------------------------------------------------------
/***************************************************************************
* *
* Production configuration for the session ID cookie name. *
* *
* We reccomend prefixing your session cookie with `__Host-`, this limits *
* the scope of your cookie to a single origin to protect against same-site *
* attacks. *
* *
* Note that with the `__Host-` prefix, session cookies will _not_ be sent *
* unless `sails.config.cookie.secure` is set to `true`. *
* *
* Read more: *
* https://sailsjs.com/config/session#?the-session-id-cookie *
* *
***************************************************************************/
// name: '__Host-sails.sid',
/***************************************************************************
* *
* Production configuration for the session ID cookie. *
* *
* Tell browsers (or other user agents) to ensure that session ID cookies *
* are always transmitted via HTTPS, and that they expire 24 hours after *
* they are set. *
* *
* Note that with `secure: true` set, session cookies will _not_ be *
* transmitted over unsecured (HTTP) connections. Also, for apps behind *
* proxies (like Heroku), the `trustProxy` setting under `http` must be *
* configured in order for `secure: true` to work. *
* *
* > While you might want to increase or decrease the `maxAge` or provide *
* > other options, you should always set `secure: true` in production *
* > if the app is being served over HTTPS. *
* *
* Read more: *
* https://sailsjs.com/config/session#?the-session-id-cookie *
* *
***************************************************************************/
cookie: {
// secure: true,
maxAge: 24 * 60 * 60 * 1000, // 24 hours
},
},
/**************************************************************************
* *
* Set up Socket.io for your production environment. *
* *
* (https://sailsjs.com/config/sockets) *
* *
* > If you have disabled the "sockets" hook, then you can safely remove *
* > this section from your `config/env/production.js` file. *
* *
***************************************************************************/
sockets: {
/***************************************************************************
* *
* Uncomment the `onlyAllowOrigins` whitelist below to configure which *
* "origins" are allowed to open socket connections to your Sails app. *
* *
* > Replace "https://example.com" etc. with the URL(s) of your app. *
* > Be sure to use the right protocol! ("http://" vs. "https://") *
* *
***************************************************************************/
// onlyAllowOrigins: [
// 'https://example.com',
// 'https://staging.example.com',
// ],
/***************************************************************************
* *
* If you are deploying a cluster of multiple servers and/or processes, *
* then uncomment the following lines. This tells Socket.io about a Redis *
* server it can use to help it deliver broadcasted socket messages. *
* *
* > Be sure a compatible version of @sailshq/socket.io-redis is installed! *
* > (See https://sailsjs.com/config/sockets for the latest version info) *
* *
* (https://sailsjs.com/docs/concepts/deployment/scaling) *
* *
***************************************************************************/
// adapter: '@sailshq/socket.io-redis',
// url: 'redis://user:password@bigsquid.redistogo.com:9562/databasenumber',
//--------------------------------------------------------------------------
// /\ OR, to avoid checking it in to version control, you might opt to
// || set sensitive credentials like this using an environment variable.
//
// For example:
// ```
// sails_sockets__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/0
// ```
//--------------------------------------------------------------------------
},
/**************************************************************************
* *
* Set the production log level. *
* *
* (https://sailsjs.com/config/log) *
* *
***************************************************************************/
log: {
level: 'debug'
},
http: {
/***************************************************************************
* *
* The number of milliseconds to cache static assets in production. *
* (the "max-age" to include in the "Cache-Control" response header) *
* *
* If you are caching assets with a tool like Cloudflare, you may want to *
* reduce this considerably to allow more flexibility in purging the cache. *
* *
***************************************************************************/
cache: 365.25 * 24 * 60 * 60 * 1000, // One year
/***************************************************************************
* *
* Proxy settings *
* *
* If your app will be deployed behind a proxy/load balancer - for example, *
* on a PaaS like Heroku - then uncomment the `trustProxy` setting below. *
* This tells Sails/Express how to interpret X-Forwarded headers. *
* *
* This setting is especially important if you are using secure cookies *
* (see the `cookies: secure` setting under `session` above) or if your app *
* relies on knowing the original IP address that a request came from. *
* *
* (https://sailsjs.com/config/http) *
* *
***************************************************************************/
// trustProxy: true,
},
/**************************************************************************
* *
* Lift the server on port 80. *
* (if deploying behind a proxy, or to a PaaS like Heroku or Deis, you *
* probably don't need to set a port here, because it is oftentimes *
* handled for you automatically. If you are not sure if you need to set *
* this, just try deploying without setting it and see if it works.) *
* *
***************************************************************************/
// port: 80,
/**************************************************************************
* *
* Configure an SSL certificate *
* *
* For the safety of your users' data, you should use SSL in production. *
* ...But in many cases, you may not actually want to set it up _here_. *
* *
* Normally, this setting is only relevant when running a single-process *
* deployment, with no proxy/load balancer in the mix. But if, on the *
* other hand, you are using a PaaS like Heroku, you'll want to set up *
* SSL in your load balancer settings (usually somewhere in your hosting *
* provider's dashboard-- not here.) *
* *
* > For more information about configuring SSL in Sails, see: *
* > https://sailsjs.com/config/*#?sailsconfigssl *
* *
**************************************************************************/
// ssl: undefined,
/**************************************************************************
* *
* Production overrides for any custom settings specific to your app. *
* (for example, production credentials for 3rd party APIs like Stripe) *
* *
* > See config/custom.js for more info on how to configure these options. *
* *
***************************************************************************/
custom: {
baseUrl: 'https://example.com',
internalEmailAddress: 'support@example.com',
// sendgridSecret: 'SG.fake.3e0Bn0qSQVnwb1E4qNPz9JZP5vLZYqjh7sn8S93oSHU',
// stripeSecret: 'sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm',
//--------------------------------------------------------------------------
// /\ OR, to avoid checking them in to version control, you might opt to
// || set sensitive credentials like these using environment variables.
//
// For example:
// ```
// sendgridSecret=SG.fake.3e0Bn0qSQVnwb1E4qNPz9JZP5vLZYqjh7sn8S93oSHU
// sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm
// ```
//--------------------------------------------------------------------------
},
};

96
config/env/staging.js vendored Normal file
View File

@ -0,0 +1,96 @@
/**
* Staging environment settings
* (sails.config.*)
*
* This is mostly a carbon copy of the production environment settings
* in config/env/production.js, but with the overrides listed below.
* For more detailed information and links about what these settings do
* see the production config file.
*
* > This file takes effect when `sails.config.environment` is "staging".
* > But note that NODE_ENV should still be "production" when lifting
* > your app in the staging environment. In other words:
* > ```
* > NODE_ENV=production sails_environment=staging node app
* > ```
*
* If you're unsure or want advice, stop by:
* https://sailsjs.com/support
*/
var PRODUCTION_CONFIG = require('./production');
//--------------------------------------------------------------------------
// /\ Start with your production config, even if it's just a guess for now,
// || then configure your staging environment afterwards.
// (That way, all you need to do in this file is set overrides.)
//--------------------------------------------------------------------------
module.exports = Object.assign({}, PRODUCTION_CONFIG, {
datastores: Object.assign({}, PRODUCTION_CONFIG.datastores, {
default: Object.assign({}, PRODUCTION_CONFIG.datastores.default, {
// url: 'mysql://shared:some_password_everyone_knows@db.example.com:3306/my_staging_db',
//--------------------------------------------------------------------------
// /\ Hard-code your staging db `url`.
// || (or use system env var: `sails_datastores__default__url`)
//--------------------------------------------------------------------------
})
}),
sockets: Object.assign({}, PRODUCTION_CONFIG.sockets, {
onlyAllowOrigins: [
'http://localhost:1337',
// 'https://example-staging.herokuapp.com',
// 'http://example-staging.herokuapp.com',
// 'https://staging.example.com',
// 'http://staging.example.com',
],
//--------------------------------------------------------------------------
// /\ Hard-code a staging-only override for allowed origins.
// || (or set this array via JSON-encoded system env var)
// ```
// sails_sockets__onlyAllowOrigins='["http://localhost:1337", "…"]'
// ```
//--------------------------------------------------------------------------
// url: 'redis://shared:some_password_everyone_knows@bigsquid.redistogo.com:9562/',
//--------------------------------------------------------------------------
// /\ Hard-code your staging Redis server's `url`.
// || (or use system env var: `sails_sockets__url`)
//--------------------------------------------------------------------------
}),
session: Object.assign({}, PRODUCTION_CONFIG.session, {
// url: 'redis://shared:some_password_everyone_knows@bigsquid.redistogo.com:9562/staging-sessions',
//--------------------------------------------------------------------------
// /\ Hard-code your staging Redis server's `url` again here.
// || (or use system env var: `sails_session__url`)
//--------------------------------------------------------------------------
}),
custom: Object.assign({}, PRODUCTION_CONFIG.custom, {
baseUrl: 'https://staging.example.com',
//--------------------------------------------------------------------------
// /\ Hard-code the base URL where your staging environment is hosted.
// || (or use system env var: `sails_custom__baseUrl`)
//--------------------------------------------------------------------------
internalEmailAddress: 'support+staging@example.com',
//--------------------------------------------------------------------------
// /\ Hard-code the email address that should receive support/contact form
// || messages in staging (or use `sails_custom__internalEmailAddress`)
//--------------------------------------------------------------------------
// sendgridSecret: 'SG.fake.3e0Bn0qSQVnwb1E4qNPz9JZP5vLZYqjh7sn8S93oSHU',
// stripeSecret: 'sk_sandbox__fake_Nfgh82401348jaDa3lkZ0d9Hm',
// stripePublishableKey: 'pk_sandbox__fake_fKd3mZJs1mlYrzWt7JQtkcRb',
//--------------------------------------------------------------------------
// /\ Hard-code credentials to use in staging for other 3rd party APIs, etc.
// || (or use system environment variables prefixed with "sails_custom__")
//--------------------------------------------------------------------------
})
});

52
config/globals.js Normal file
View File

@ -0,0 +1,52 @@
/**
* Global Variable Configuration
* (sails.config.globals)
*
* Configure which global variables which will be exposed
* automatically by Sails.
*
* For more information on any of these options, check out:
* https://sailsjs.com/config/globals
*/
module.exports.globals = {
/****************************************************************************
* *
* Whether to expose the locally-installed Lodash as a global variable *
* (`_`), making it accessible throughout your app. *
* *
****************************************************************************/
_: require('@sailshq/lodash'),
/****************************************************************************
* *
* This app was generated without a dependency on the "async" NPM package. *
* *
* > Don't worry! This is totally unrelated to JavaScript's "async/await". *
* > Your code can (and probably should) use `await` as much as possible. *
* *
****************************************************************************/
async: false,
/****************************************************************************
* *
* Whether to expose each of your app's models as global variables. *
* (See the link at the top of this file for more information.) *
* *
****************************************************************************/
models: true,
/****************************************************************************
* *
* Whether to expose the Sails app instance as a global variable (`sails`), *
* making it accessible throughout your app. *
* *
****************************************************************************/
sails: true,
};

60
config/http.js Normal file
View File

@ -0,0 +1,60 @@
/**
* HTTP Server Settings
* (sails.config.http)
*
* Configuration for the underlying HTTP server in Sails.
* (for additional recommended settings, see `config/env/production.js`)
*
* For more information on configuration, check out:
* https://sailsjs.com/config/http
*/
module.exports.http = {
/****************************************************************************
* *
* Sails/Express middleware to run for every HTTP request. *
* (Only applies to HTTP requests -- not virtual WebSocket requests.) *
* *
* https://sailsjs.com/documentation/concepts/middleware *
* *
****************************************************************************/
middleware: {
/***************************************************************************
* *
* The order in which middleware should be run for HTTP requests. *
* (This Sails app's routes are handled by the "router" middleware below.) *
* *
***************************************************************************/
// order: [
// 'cookieParser',
// 'session',
// 'bodyParser',
// 'compress',
// 'poweredBy',
// 'router',
// 'www',
// 'favicon',
// ],
/***************************************************************************
* *
* The body parser that will handle incoming multipart HTTP requests. *
* *
* https://sailsjs.com/config/http#?customizing-the-body-parser *
* *
***************************************************************************/
// bodyParser: (function _configureBodyParser(){
// var skipper = require('skipper');
// var middlewareFn = skipper({ strict: true });
// return middlewareFn;
// })(),
},
};

45
config/i18n.js Normal file
View File

@ -0,0 +1,45 @@
/**
* Internationalization / Localization Settings
* (sails.config.i18n)
*
* If your app will touch people from all over the world, i18n (or internationalization)
* may be an important part of your international strategy.
*
* For a complete list of options for Sails' built-in i18n support, see:
* https://sailsjs.com/config/i-18-n
*
* For more info on i18n in Sails in general, check out:
* https://sailsjs.com/docs/concepts/internationalization
*/
module.exports.i18n = {
/***************************************************************************
* *
* Which locales are supported? *
* *
***************************************************************************/
locales: ['en', 'es', 'fr', 'de'],
/****************************************************************************
* *
* What is the default locale for the site? Note that this setting will be *
* overridden for any request that sends an "Accept-Language" header (i.e. *
* most browsers), but it's still useful if you need to localize the *
* response for requests made by non-browser clients (e.g. cURL). *
* *
****************************************************************************/
// defaultLocale: 'en',
/****************************************************************************
* *
* Path (relative to app root) of directory to store locale (translation) *
* files in. *
* *
****************************************************************************/
// localesDirectory: 'config/locales'
};

4
config/locales/de.json Normal file
View File

@ -0,0 +1,4 @@
{
"Welcome": "Willkommen",
"A brand new app.": "Eine neue App."
}

4
config/locales/en.json Normal file
View File

@ -0,0 +1,4 @@
{
"Welcome": "Welcome",
"A brand new app.": "A brand new app."
}

4
config/locales/es.json Normal file
View File

@ -0,0 +1,4 @@
{
"Welcome": "Bienvenido",
"A brand new app.": "Una nueva aplicación."
}

4
config/locales/fr.json Normal file
View File

@ -0,0 +1,4 @@
{
"Welcome": "Bienvenue",
"A brand new app.": "Une toute nouvelle application."
}

29
config/log.js Normal file
View File

@ -0,0 +1,29 @@
/**
* Built-in Log Configuration
* (sails.config.log)
*
* Configure the log level for your app, as well as the transport
* (Underneath the covers, Sails uses Winston for logging, which
* allows for some pretty neat custom transports/adapters for log messages)
*
* For more information on the Sails logger, check out:
* https://sailsjs.com/docs/concepts/logging
*/
module.exports.log = {
/***************************************************************************
* *
* Valid `level` configs: i.e. the minimum log level to capture with *
* sails.log.*() *
* *
* The order of precedence for log levels from lowest to highest is: *
* silly, verbose, info, debug, warn, error *
* *
* You may also set the level to "silent" to suppress all logs. *
* *
***************************************************************************/
// level: 'info'
};

124
config/models.js Normal file
View File

@ -0,0 +1,124 @@
/**
* Default model settings
* (sails.config.models)
*
* Your default, project-wide model settings. Can also be overridden on a
* per-model basis by setting a top-level properties in the model definition.
*
* For details about all available model settings, see:
* https://sailsjs.com/config/models
*
* For more general background on Sails model settings, and how to configure
* them on a project-wide or per-model basis, see:
* https://sailsjs.com/docs/concepts/models-and-orm/model-settings
*/
module.exports.models = {
/***************************************************************************
* *
* Whether model methods like `.create()` and `.update()` should ignore *
* (and refuse to persist) unrecognized data-- i.e. properties other than *
* those explicitly defined by attributes in the model definition. *
* *
* To ease future maintenance of your code base, it is usually a good idea *
* to set this to `true`. *
* *
* > Note that `schema: false` is not supported by every database. *
* > For example, if you are using a SQL database, then relevant models *
* > are always effectively `schema: true`. And if no `schema` setting is *
* > provided whatsoever, the behavior is left up to the database adapter. *
* > *
* > For more info, see: *
* > https://sailsjs.com/docs/concepts/orm/model-settings#?schema *
* *
***************************************************************************/
schema: true,
/***************************************************************************
* *
* How and whether Sails will attempt to automatically rebuild the *
* tables/collections/etc. in your schema. *
* *
* > Note that, when running in a production environment, this will be *
* > automatically set to `migrate: 'safe'`, no matter what you configure *
* > here. This is a failsafe to prevent Sails from accidentally running *
* > auto-migrations on your production database. *
* > *
* > For more info, see: *
* > https://sailsjs.com/docs/concepts/orm/model-settings#?migrate *
* *
***************************************************************************/
migrate: 'alter',
/***************************************************************************
* *
* Base attributes that are included in all of your models by default. *
* By convention, this is your primary key attribute (`id`), as well as two *
* other timestamp attributes for tracking when records were last created *
* or updated. *
* *
* > For more info, see: *
* > https://sailsjs.com/docs/concepts/orm/model-settings#?attributes *
* *
***************************************************************************/
attributes: {
createdAt: { type: 'number', autoCreatedAt: true, },
updatedAt: { type: 'number', autoUpdatedAt: true, },
id: { type: 'number', autoIncrement: true, },
//--------------------------------------------------------------------------
// /\ Using MongoDB?
// || Replace `id` above with this instead:
//
// ```
// id: { type: 'string', columnName: '_id' },
// ```
//
// Plus, don't forget to configure MongoDB as your default datastore:
// https://sailsjs.com/docs/tutorials/using-mongo-db
//--------------------------------------------------------------------------
},
/******************************************************************************
* *
* The set of DEKs (data encryption keys) for at-rest encryption. *
* i.e. when encrypting/decrypting data for attributes with `encrypt: true`. *
* *
* > The `default` DEK is used for all new encryptions, but multiple DEKs *
* > can be configured to allow for key rotation. In production, be sure to *
* > manage these keys like you would any other sensitive credential. *
* *
* > For more info, see: *
* > https://sailsjs.com/docs/concepts/orm/model-settings#?dataEncryptionKeys *
* *
******************************************************************************/
dataEncryptionKeys: {
default: '0ZYbQGmcsbjbwFwNVbVDqzIEp+wb4uVRxSkxLJnQ/Vs='
},
/***************************************************************************
* *
* Whether or not implicit records for associations should be cleaned up *
* automatically using the built-in polyfill. This is especially useful *
* during development with sails-disk. *
* *
* Depending on which databases you're using, you may want to disable this *
* polyfill in your production environment. *
* *
* (For production configuration, see `config/env/production.js`.) *
* *
***************************************************************************/
cascadeOnDestroy: true
};

25
config/policies.js Normal file
View File

@ -0,0 +1,25 @@
/**
* Policy Mappings
* (sails.config.policies)
*
* Policies are simple functions which run **before** your actions.
*
* For more information on configuring policies, check out:
* https://sailsjs.com/docs/concepts/policies
*/
module.exports.policies = {
'*': 'is-logged-in',
// Bypass the `is-logged-in` policy for:
'entrance/*': true,
'account/logout': true,
'view-homepage-or-redirect': true,
'view-faq': true,
'view-contact': true,
'legal/view-terms': true,
'legal/view-privacy': true,
'deliver-contact-form-message': true,
};

66
config/routes.js Normal file
View File

@ -0,0 +1,66 @@
/**
* Route Mappings
* (sails.config.routes)
*
* Your routes tell Sails what to do each time it receives a request.
*
* For more information on configuring custom routes, check out:
* https://sailsjs.com/anatomy/config/routes-js
*/
module.exports.routes = {
// ╦ ╦╔═╗╔╗ ╔═╗╔═╗╔═╗╔═╗╔═╗
// ║║║║╣ ╠╩╗╠═╝╠═╣║ ╦║╣ ╚═╗
// ╚╩╝╚═╝╚═╝╩ ╩ ╩╚═╝╚═╝╚═╝
'GET /': { action: 'view-homepage-or-redirect' },
'GET /welcome/:unused?': { action: 'dashboard/view-welcome' },
'GET /faq': { action: 'view-faq' },
'GET /legal/terms': { action: 'legal/view-terms' },
'GET /legal/privacy': { action: 'legal/view-privacy' },
'GET /contact': { action: 'view-contact' },
'GET /signup': { action: 'entrance/view-signup' },
'GET /email/confirm': { action: 'entrance/confirm-email' },
'GET /email/confirmed': { action: 'entrance/view-confirmed-email' },
'GET /login': { action: 'entrance/view-login' },
'GET /password/forgot': { action: 'entrance/view-forgot-password' },
'GET /password/new': { action: 'entrance/view-new-password' },
'GET /account': { action: 'account/view-account-overview' },
'GET /account/password': { action: 'account/view-edit-password' },
'GET /account/profile': { action: 'account/view-edit-profile' },
// ╔╦╗╦╔═╗╔═╗ ╦═╗╔═╗╔╦╗╦╦═╗╔═╗╔═╗╔╦╗╔═╗ ┬ ╔╦╗╔═╗╦ ╦╔╗╔╦ ╔═╗╔═╗╔╦╗╔═╗
// ║║║║╚═╗║ ╠╦╝║╣ ║║║╠╦╝║╣ ║ ║ ╚═╗ ┌┼─ ║║║ ║║║║║║║║ ║ ║╠═╣ ║║╚═╗
// ╩ ╩╩╚═╝╚═╝ ╩╚═╚═╝═╩╝╩╩╚═╚═╝╚═╝ ╩ ╚═╝ └┘ ═╩╝╚═╝╚╩╝╝╚╝╩═╝╚═╝╩ ╩═╩╝╚═╝
'/terms': '/legal/terms',
'/logout': '/api/v1/account/logout',
// ╦ ╦╔═╗╔╗ ╦ ╦╔═╗╔═╗╦╔═╔═╗
// ║║║║╣ ╠╩╗╠═╣║ ║║ ║╠╩╗╚═╗
// ╚╩╝╚═╝╚═╝╩ ╩╚═╝╚═╝╩ ╩╚═╝
// …
// ╔═╗╔═╗╦ ╔═╗╔╗╔╔╦╗╔═╗╔═╗╦╔╗╔╔╦╗╔═╗
// ╠═╣╠═╝║ ║╣ ║║║ ║║╠═╝║ ║║║║║ ║ ╚═╗
// ╩ ╩╩ ╩ ╚═╝╝╚╝═╩╝╩ ╚═╝╩╝╚╝ ╩ ╚═╝
// Note that, in this app, these API endpoints may be accessed using the `Cloud.*()` methods
// from the Parasails library, or by using those method names as the `action` in <ajax-form>.
'/api/v1/account/logout': { action: 'account/logout' },
'PUT /api/v1/account/update-password': { action: 'account/update-password' },
'PUT /api/v1/account/update-profile': { action: 'account/update-profile' },
'PUT /api/v1/account/update-billing-card': { action: 'account/update-billing-card' },
'PUT /api/v1/entrance/login': { action: 'entrance/login' },
'POST /api/v1/entrance/signup': { action: 'entrance/signup' },
'POST /api/v1/entrance/send-password-recovery-email': { action: 'entrance/send-password-recovery-email' },
'POST /api/v1/entrance/update-password-and-login': { action: 'entrance/update-password-and-login' },
'POST /api/v1/deliver-contact-form-message': { action: 'deliver-contact-form-message' },
'POST /api/v1/observe-my-session': { action: 'observe-my-session', hasSocketFeatures: true },
};

49
config/security.js Normal file
View File

@ -0,0 +1,49 @@
/**
* Security Settings
* (sails.config.security)
*
* These settings affect aspects of your app's security, such
* as how it deals with cross-origin requests (CORS) and which
* routes require a CSRF token to be included with the request.
*
* For an overview of how Sails handles security, see:
* https://sailsjs.com/documentation/concepts/security
*
* For additional options and more information, see:
* https://sailsjs.com/config/security
*/
module.exports.security = {
/***************************************************************************
* *
* CORS is like a more modern version of JSONP-- it allows your application *
* to circumvent browsers' same-origin policy, so that the responses from *
* your Sails app hosted on one domain (e.g. example.com) can be received *
* in the client-side JavaScript code from a page you trust hosted on _some *
* other_ domain (e.g. trustedsite.net). *
* *
* For additional options and more information, see: *
* https://sailsjs.com/docs/concepts/security/cors *
* *
***************************************************************************/
// cors: {
// allRoutes: false,
// allowOrigins: '*',
// allowCredentials: false,
// },
/****************************************************************************
* *
* CSRF protection should be enabled for this application. *
* *
* For more information, see: *
* https://sailsjs.com/docs/concepts/security/csrf *
* *
****************************************************************************/
csrf: true
};

39
config/session.js Normal file
View File

@ -0,0 +1,39 @@
/**
* Session Configuration
* (sails.config.session)
*
* Use the settings below to configure session integration in your app.
* (for additional recommended settings, see `config/env/production.js`)
*
* For all available options, see:
* https://sailsjs.com/config/session
*/
module.exports.session = {
/***************************************************************************
* *
* Session secret is automatically generated when your new app is created *
* Replace at your own risk in production-- you will invalidate the cookies *
* of your users, forcing them to log in again. *
* *
***************************************************************************/
secret: '0a9bbfee6b2675c68da79bf3e887face',
/***************************************************************************
* *
* Customize when built-in session support will be skipped. *
* *
* (Useful for performance tuning; particularly to avoid wasting cycles on *
* session management when responding to simple requests for static assets, *
* like images or stylesheets.) *
* *
* https://sailsjs.com/config/session *
* *
***************************************************************************/
// isSessionDisabled: function (req){
// return !!req.path.match(req._sails.LOOKS_LIKE_ASSET_RX);
// },
};

82
config/sockets.js Normal file
View File

@ -0,0 +1,82 @@
/**
* WebSocket Server Settings
* (sails.config.sockets)
*
* Use the settings below to configure realtime functionality in your app.
* (for additional recommended settings, see `config/env/production.js`)
*
* For all available options, see:
* https://sailsjs.com/config/sockets
*/
module.exports.sockets = {
/***************************************************************************
* *
* `transports` *
* *
* The protocols or "transports" that socket clients are permitted to *
* use when connecting and communicating with this Sails application. *
* *
* > Never change this here without also configuring `io.sails.transports` *
* > in your client-side code. If the client and the server are not using *
* > the same array of transports, sockets will not work properly. *
* > *
* > For more info, see: *
* > https://sailsjs.com/docs/reference/web-sockets/socket-client *
* *
***************************************************************************/
// transports: [ 'websocket' ],
/***************************************************************************
* *
* `beforeConnect` *
* *
* This custom beforeConnect function will be run each time BEFORE a new *
* socket is allowed to connect, when the initial socket.io handshake is *
* performed with the server. *
* *
* https://sailsjs.com/config/sockets#?beforeconnect *
* *
***************************************************************************/
// beforeConnect: function(handshake, proceed) {
//
// // `true` allows the socket to connect.
// // (`false` would reject the connection)
// return proceed(undefined, true);
//
// },
/***************************************************************************
* *
* `afterDisconnect` *
* *
* This custom afterDisconnect function will be run each time a socket *
* disconnects *
* *
***************************************************************************/
// afterDisconnect: function(session, socket, done) {
//
// // By default: do nothing.
// // (but always trigger the callback)
// return done();
//
// },
/***************************************************************************
* *
* Whether to expose a 'GET /__getcookie' route that sets an HTTP-only *
* session cookie. *
* *
***************************************************************************/
// grant3rdPartyCookie: true,
};

41
config/views.js Normal file
View File

@ -0,0 +1,41 @@
/**
* View Engine Configuration
* (sails.config.views)
*
* Server-sent views are a secure and effective way to get your app up
* and running. Views are normally served from actions. Below, you can
* configure your templating language/framework of choice and configure
* Sails' layout support.
*
* For details on available options for configuring server-side views, check out:
* https://sailsjs.com/config/views
*
* For more background information on views and partials in Sails, check out:
* https://sailsjs.com/docs/concepts/views
*/
module.exports.views = {
/***************************************************************************
* *
* Extension to use for your views. When calling `res.view()` in an action, *
* you can leave this extension off. For example, calling *
* `res.view('homepage')` will (using default settings) look for a *
* `views/homepage.ejs` file. *
* *
***************************************************************************/
// extension: 'ejs',
/***************************************************************************
* *
* The path (relative to the views directory, and without extension) to *
* the default layout file to use, or `false` to disable layouts entirely. *
* *
* Note that layouts only work with the built-in EJS view engine! *
* *
***************************************************************************/
layout: 'layouts/layout'
};