init sails app

pull/1/head
unknown 2018-10-15 21:45:37 -04:00
commit 4cf1ee413e
72 changed files with 5347 additions and 0 deletions

31
.editorconfig Normal file
View File

@ -0,0 +1,31 @@
################################################
# ╔═╗╔╦╗╦╔╦╗╔═╗╦═╗┌─┐┌─┐┌┐┌┌─┐┬┌─┐
# ║╣ ║║║ ║ ║ ║╠╦╝│ │ ││││├┤ ││ ┬
# o╚═╝═╩╝╩ ╩ ╚═╝╩╚═└─┘└─┘┘└┘└ ┴└─┘
#
# > Formatting conventions for your Sails app.
#
# This file (`.editorconfig`) exists to help
# maintain consistent formatting throughout the
# files in your Sails app.
#
# For the sake of convention, the Sails team's
# preferred settings are included here out of the
# box. You can also change this file to fit your
# team's preferences (for example, if all of the
# developers on your team have a strong preference
# for tabs over spaces),
#
# To review what each of these options mean, see:
# http://editorconfig.org/
#
################################################
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
assets/dependencies/**/*.js
views/**/*.ejs

93
.eslintrc Normal file
View File

@ -0,0 +1,93 @@
{
// ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐
// ║╣ ╚═╗║ ║║║║ ║ ├┬┘│
// o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘
// A set of basic code conventions (similar to a .jshintrc file) designed to
// encourage quality and consistency across your Sails app's code base.
// These rules are checked against automatically any time you run `npm test`.
//
// > An additional eslintrc override file is included in the `assets/` folder
// > right out of the box. This is specifically to allow for variations in acceptable
// > global variables between front-end JavaScript code designed to run in the browser
// > vs. backend code designed to run in a Node.js/Sails process.
//
// > Note: If you're using mocha, you'll want to add an extra override file to your
// > `test/` folder so that eslint will tolerate mocha-specific globals like `before`
// > and `describe`.
// Designed for ESLint v4.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// For more information about any of the rules below, check out the relevant
// reference page on eslint.org. For example, to get details on "no-sequences",
// you would visit `http://eslint.org/docs/rules/no-sequences`. If you're unsure
// or could use some advice, come by https://sailsjs.com/support.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 8,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"globals": {
// If "no-undef" is enabled below, be sure to list all global variables that
// are used in this app's backend code (including the globalIds of models):
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Promise": true,
"sails": true,
"_": true,
"async": true
// …and any others (e.g. `"Organization": true`)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
},
"rules": {
"callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]],
"camelcase": ["warn", {"properties":"always"}],
"comma-style": ["warn", "last"],
"curly": ["error"],
"eqeqeq": ["error", "always"],
"eol-last": ["warn"],
"handle-callback-err": ["error"],
"indent": ["warn", 2, {
"SwitchCase": 1,
"MemberExpression": "off",
"FunctionDeclaration": {"body":1, "parameters":"off"},
"FunctionExpression": {"body":1, "parameters":"off"},
"CallExpression": {"arguments":"off"},
"ArrayExpression": 1,
"ObjectExpression": 1,
"ignoredNodes": ["ConditionalExpression"]
}],
"linebreak-style": ["error", "unix"],
"no-dupe-keys": ["error"],
"no-duplicate-case": ["error"],
"no-extra-semi": ["warn"],
"no-labels": ["error"],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-redeclare": ["warn"],
"no-return-assign": ["error", "always"],
"no-sequences": ["error"],
"no-trailing-spaces": ["warn"],
"no-undef": ["off"],
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ^^Note: If this "no-undef" rule is enabled (set to `["error"]`), then all model globals
// (e.g. `"Organization": true`) should be included above under "globals".
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"no-unexpected-multiline": ["warn"],
"no-unreachable": ["warn"],
"no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }],
"no-use-before-define": ["error", {"functions":false}],
"one-var": ["warn", "never"],
"prefer-arrow-callback": ["warn", {"allowNamedFunctions":true}],
"quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}],
"semi": ["error", "always"],
"semi-spacing": ["warn", {"before":false, "after":true}],
"semi-style": ["warn", "last"]
}
}

132
.gitignore vendored Normal file
View File

@ -0,0 +1,132 @@
################################################
# ┌─┐┬┌┬┐╦╔═╗╔╗╔╔═╗╦═╗╔═╗
# │ ┬│ │ ║║ ╦║║║║ ║╠╦╝║╣
# o└─┘┴ ┴ ╩╚═╝╝╚╝╚═╝╩╚═╚═╝
#
# > Files to exclude from your app's repo.
#
# This file (`.gitignore`) is only relevant if
# you are using git.
#
# It exists to signify to git that certain files
# and/or directories should be ignored for the
# purposes of version control.
#
# This keeps tmp files and sensitive credentials
# from being uploaded to your repository. And
# it allows you to configure your app for your
# machine without accidentally committing settings
# which will smash the local settings of other
# developers on your team.
#
# Some reasonable defaults are included below,
# but, of course, you should modify/extend/prune
# to fit your needs!
#
################################################
################################################
# Local Configuration
#
# Explicitly ignore files which contain:
#
# 1. Sensitive information you'd rather not push to
# your git repository.
# e.g., your personal API keys or passwords.
#
# 2. Developer-specific configuration
# Basically, anything that would be annoying
# to have to change every time you do a
# `git pull` on your laptop.
# e.g. your local development database, or
# the S3 bucket you're using for file uploads
# during development.
#
################################################
config/local.js
################################################
# Dependencies
#
#
# When releasing a production app, you _could_
# hypothetically include your node_modules folder
# in your git repo, but during development, it
# is always best to exclude it, since different
# developers may be working on different kernels,
# where dependencies would need to be recompiled
# anyway.
#
# Most of the time, the node_modules folder can
# be excluded from your code repository, even
# in production, thanks to features like the
# package-lock.json file / NPM shrinkwrap.
#
# But no matter what, since this is a Sails app,
# you should always push up the package-lock.json
# or shrinkwrap file to your repository, to avoid
# accidentally pulling in upgraded dependencies
# and breaking your code.
#
# That said, if you are having trouble with
# dependencies, (particularly when using
# `npm link`) this can be pretty discouraging.
# But rather than just adding the lockfile to
# your .gitignore, try this first:
# ```
# rm -rf node_modules
# rm package-lock.json
# npm install
# ```
#
# [?] For more tips/advice, come by and say hi
# over at https://sailsjs.com/support
#
################################################
node_modules
################################################
#
# > Do you use bower?
# > re: the bower_components dir, see this:
# > http://addyosmani.com/blog/checking-in-front-end-dependencies/
# > (credit Addy Osmani, @addyosmani)
#
################################################
################################################
# Temporary files generated by Sails/Waterline.
################################################
.tmp
################################################
# Miscellaneous
#
# Common files generated by text editors,
# operating systems, file systems, dbs, etc.
################################################
*~
*#
.DS_STORE
.netbeans
nbproject
.idea
.node_history
dump.rdb
npm-debug.log
lib-cov
*.seed
*.log
*.out
*.pid

9
.sailsrc Normal file
View File

@ -0,0 +1,9 @@
{
"generators": {
"modules": {}
},
"_generatedWith": {
"sails": "1.0.2",
"sails-generate": "1.15.28"
}
}

23
Gruntfile.js Normal file
View File

@ -0,0 +1,23 @@
/**
* Gruntfile
*
* This Node script is executed when you run `grunt`-- and also when
* you run `sails lift` (provided the grunt hook is installed and
* hasn't been disabled).
*
* WARNING:
* Unless you know what you're doing, you shouldn't change this file.
* Check out the `tasks/` directory instead.
*
* For more information see:
* https://sailsjs.com/anatomy/Gruntfile.js
*/
module.exports = function(grunt) {
var loadGruntTasks = require('sails-hook-grunt/accessible/load-grunt-tasks');
// Load Grunt task configurations (from `tasks/config/`) and Grunt
// task registrations (from `tasks/register/`).
loadGruntTasks(__dirname, grunt);
};

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# roe-base
a [Sails v1](https://sailsjs.com) application
### 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)
### Version info
This app was originally generated on Tue Oct 16 2018 01:21:31 GMT+0000 (UTC) using Sails v1.0.2.
<!-- Internally, Sails used [`sails-generate@1.15.28`](https://github.com/balderdashy/sails-generate/tree/v1.15.28/lib/core-generators/new). -->
<!--
Note: Generators are usually run using the globally-installed `sails` CLI (command-line interface). This CLI version is _environment-specific_ rather than app-specific, thus over time, as a project's dependencies are upgraded or the project is worked on by different developers on different computers using different versions of Node.js, the Sails dependency in its package.json file may differ from the globally-installed Sails CLI release it was originally generated with. (Be sure to always check out the relevant [upgrading guides](https://sailsjs.com/upgrading) before upgrading the version of Sails used by your app. If you're stuck, [get help here](https://sailsjs.com/support).)
-->

0
api/controllers/.gitkeep Normal file
View File

0
api/helpers/.gitkeep Normal file
View File

0
api/models/.gitkeep Normal file
View File

0
api/policies/.gitkeep Normal file
View File

54
app.js Normal file
View File

@ -0,0 +1,54 @@
/**
* app.js
*
* Use `app.js` to run your app without `sails lift`.
* To start the server, run: `node app.js`.
*
* This is handy in situations where the sails CLI is not relevant or useful,
* such as when you deploy to a server, or a PaaS like Heroku.
*
* For example:
* => `node app.js`
* => `npm start`
* => `forever start app.js`
* => `node debug app.js`
*
* The same command-line arguments and env vars are supported, e.g.:
* `NODE_ENV=production node app.js --port=80 --verbose`
*
* For more information see:
* https://sailsjs.com/anatomy/app.js
*/
// Ensure we're in the project directory, so cwd-relative paths work as expected
// no matter where we actually lift from.
// > Note: This is not required in order to lift, but it is a convenient default.
process.chdir(__dirname);
// Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files).
var sails;
var rc;
try {
sails = require('sails');
rc = require('sails/accessible/rc');
} catch (err) {
console.error('Encountered an error when attempting to require(\'sails\'):');
console.error(err.stack);
console.error('--');
console.error('To run an app using `node app.js`, you need to have Sails installed');
console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re');
console.error('in the same directory as your app and run `npm install`.');
console.error();
console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can');
console.error('also run this app with `sails lift`. Running with `sails lift` will');
console.error('not run this file (`app.js`), but it will do exactly the same thing.');
console.error('(It even uses your app directory\'s local Sails install, if possible.)');
return;
}//-•
// Start server
sails.lift(rc('sails'));

62
assets/.eslintrc Normal file
View File

@ -0,0 +1,62 @@
{
// ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐ ┌─┐┬ ┬┌─┐┬─┐┬─┐┬┌┬┐┌─┐
// ║╣ ╚═╗║ ║║║║ ║ ├┬┘│ │ │└┐┌┘├┤ ├┬┘├┬┘│ ││├┤
// o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘ └─┘ └┘ └─┘┴└─┴└─┴─┴┘└─┘
// ┌─ ┌─┐┌─┐┬─┐ ┌┐ ┬─┐┌─┐┬ ┬┌─┐┌─┐┬─┐ ┬┌─┐ ┌─┐┌─┐┌─┐┌─┐┌┬┐┌─┐ ─┐
// │ ├┤ │ │├┬┘ ├┴┐├┬┘│ ││││└─┐├┤ ├┬┘ │└─┐ ├─┤└─┐└─┐├┤ │ └─┐ │
// └─ └ └─┘┴└─ └─┘┴└─└─┘└┴┘└─┘└─┘┴└─ └┘└─┘ ┴ ┴└─┘└─┘└─┘ ┴ └─┘ ─┘
// > An .eslintrc configuration override for use in the `assets/` directory.
//
// This extends the top-level .eslintrc file, primarily to change the set of
// supported globals, as well as any other relevant settings. (Since JavaScript
// code in the `assets/` folder is intended for the browser habitat, a different
// set of globals is supported. For example, instead of Node.js/Sails globals
// like `sails` and `process`, you have access to browser globals like `window`.)
//
// (See .eslintrc in the root directory of this Sails app for more context.)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"extends": [
"../.eslintrc"
],
"env": {
"browser": true,
"node": false
},
"parserOptions": {
"ecmaVersion": 8
//^ If you are not using a transpiler like Babel, change this to `5`.
},
"globals": {
// Allow any window globals you're relying on here; e.g.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"SAILS_LOCALS": true,
"io": true,
// "moment": true,
// ...etc.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Make sure backend globals aren't indadvertently tolerated in our client-side JS:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"sails": false,
"_": false,
"async": false
// ...and any other backend globals (e.g. `"Organization": false`)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
},
"rules": {
"no-undef": ["error"]
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ^^Note: If you've enabled the "no-undef" rule in the top level .eslintrc file, then
// the globalIds of Sails models should also be blacklisted above under "globals".
// (In this scenario, also note that this override for the "no-undef" rule could
// simply be removed, since it'd be redundant.)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}
}

View File

File diff suppressed because one or more lines are too long

BIN
assets/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

0
assets/images/.gitkeep Normal file
View File

0
assets/js/.gitkeep Normal file
View File

9
assets/robots.txt Normal file
View File

@ -0,0 +1,9 @@
# The robots.txt file is used to control how search engines index your live URLs.
# See https://sailsjs.com/anatomy/assets/robots-txt for more information.
# If you want to discourage search engines from indexing this site, uncomment
# the "User-Agent" and "Disallow" settings on the next two lines:
# User-Agent: *
# Disallow: /

View File

@ -0,0 +1,24 @@
/**
* importer.less
*
* By default, new Sails projects are configured to compile this file
* from LESS to CSS. Unlike CSS files, LESS files are not compiled and
* included automatically unless they are imported below.
*
* For more information see:
* https://sailsjs.com/anatomy/assets/styles/importer-less
*/
// For example:
//
// @import 'variables/colors.less';
// @import 'mixins/foo.less';
// @import 'mixins/bar.less';
// @import 'mixins/baz.less';
//
// @import 'styleguide.less';
// @import 'pages/login.less';
// @import 'pages/signup.less';
//
// etc.

View File

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: true,
/***************************************************************************
* *
* Automatically expose CRUD "shortcut" routes to GET requests? *
* (These are enabled by default in development only.) *
* *
***************************************************************************/
// shortcuts: true,
};

34
config/bootstrap.js Normal file
View File

@ -0,0 +1,34 @@
/**
* Bootstrap
* (sails.config.bootstrap)
*
* An asynchronous bootstrap function that runs just before your Sails app gets lifted.
* > Need more flexibility? You can also do this by creating a hook.
*
* For more information on bootstrapping your app, check out:
* https://sailsjs.com/config/bootstrap
*/
module.exports.bootstrap = async function(done) {
// By convention, this is a good place to set up fake data during development.
//
// For example:
// ```
// // Set up fake development data (or if we already have some, avast)
// if (await User.count() > 0) {
// return done();
// }
//
// await User.createEach([
// { emailAddress: 'ry@example.com', fullName: 'Ryan Dahl', },
// { emailAddress: 'rachael@example.com', fullName: 'Rachael Shaw', },
// // etc.
// ]);
// ```
// Don't forget to trigger `done()` when this bootstrap function's logic is finished.
// (otherwise your server will never lift, since it's waiting on the bootstrap)
return done();
};

23
config/custom.js Normal file
View File

@ -0,0 +1,23 @@
/**
* 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 = {
/***************************************************************************
* *
* Any other custom config this Sails app should use during development. *
* *
***************************************************************************/
// mailgunDomain: 'transactional-mail.example.com',
// mailgunSecret: 'key-testkeyb183848139913858e8abd9a3',
// stripeSecret: 'sk_test_Zzd814nldl91104qor5911gjald',
// …
};

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',
},
};

370
config/env/development.js vendored Normal file
View File

@ -0,0 +1,370 @@
/**
* Development 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: true` option is mandatory and must be provided. *
*                         *
* More info:                   *
* https://sailsjs.com/config/datastores           *
*                         *
****************************************************************************/
// ssl: 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. *
* *
* 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) *
* *
***************************************************************************/
cache: 60 * 1000 // One minute
/***************************************************************************
* *
* 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: 3000,
/**************************************************************************
* *
* 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'
// mailgunDomain: 'mg.example.com',
// mailgunSecret: 'key-prod_fake_bd32301385130a0bafe030c',
// 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:
// ```
// sails_custom__mailgunDomain=mg.example.com
// sails_custom__mailgunSecret=key-prod_fake_bd32301385130a0bafe030c
// sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm
// ```
// --------------------------------------------------------------------------
}
}

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

@ -0,0 +1,370 @@
/**
* 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: true` option is mandatory and must be provided. *
*                         *
* More info:                   *
* https://sailsjs.com/config/datastores           *
*                         *
****************************************************************************/
// ssl: 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. *
* *
* 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) *
* *
***************************************************************************/
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'
// mailgunDomain: 'mg.example.com',
// mailgunSecret: 'key-prod_fake_bd32301385130a0bafe030c',
// 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:
// ```
// sails_custom__mailgunDomain=mg.example.com
// sails_custom__mailgunSecret=key-prod_fake_bd32301385130a0bafe030c
// sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm
// ```
// --------------------------------------------------------------------------
}
}

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. *
* (See the link above for help.) *
* *
****************************************************************************/
_: require('@sailshq/lodash'),
/****************************************************************************
* *
* Whether to expose the locally-installed `async` as a global variable *
* (`async`), making it accessible throughout your app. *
* (See the link above for help.) *
* *
****************************************************************************/
async: require('async'),
/****************************************************************************
* *
* 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 the `.create()` and `.update()` model methods 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: 'nuF29j3StsGhRTut9dIrCxCNyYegcwH30FxnZ3kkdiA='
},
/***************************************************************************
* *
* 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
};

22
config/policies.js Normal file
View File

@ -0,0 +1,22 @@
/**
* 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 = {
/***************************************************************************
* *
* Default policy for all controllers and actions, unless overridden. *
* (`true` allows public access) *
* *
***************************************************************************/
// '*': true,
};

59
config/routes.js Normal file
View File

@ -0,0 +1,59 @@
/**
* 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 = {
// ╦ ╦╔═╗╔╗ ╔═╗╔═╗╔═╗╔═╗╔═╗
// ║║║║╣ ╠╩╗╠═╝╠═╣║ ╦║╣ ╚═╗
// ╚╩╝╚═╝╚═╝╩ ╩ ╩╚═╝╚═╝╚═╝
/***************************************************************************
* *
* Make the view located at `views/homepage.ejs` your home page. *
* *
* (Alternatively, remove this and add an `index.html` file in your *
* `assets` directory) *
* *
***************************************************************************/
'/': {
view: 'pages/homepage'
},
/***************************************************************************
* *
* More custom routes here... *
* (See https://sailsjs.com/config/routes for examples.) *
* *
* If a request to a URL doesn't match any of the routes in this file, it *
* is matched against "shadow routes" (e.g. blueprint routes). If it does *
* not match any of those, it is matched against static assets. *
* *
***************************************************************************/
// ╔═╗╔═╗╦ ╔═╗╔╗╔╔╦╗╔═╗╔═╗╦╔╗╔╔╦╗╔═╗
// ╠═╣╠═╝║ ║╣ ║║║ ║║╠═╝║ ║║║║║ ║ ╚═╗
// ╩ ╩╩ ╩ ╚═╝╝╚╝═╩╝╩ ╚═╝╩╝╚╝ ╩ ╚═╝
// ╦ ╦╔═╗╔╗ ╦ ╦╔═╗╔═╗╦╔═╔═╗
// ║║║║╣ ╠╩╗╠═╣║ ║║ ║╠╩╗╚═╗
// ╚╩╝╚═╝╚═╝╩ ╩╚═╝╚═╝╩ ╩╚═╝
// ╔╦╗╦╔═╗╔═╗
// ║║║║╚═╗║
// ╩ ╩╩╚═╝╚═╝
};

54
config/security.js Normal file
View File

@ -0,0 +1,54 @@
/**
* 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,
// },
/****************************************************************************
* *
* By default, Sails' built-in CSRF protection is disabled to facilitate *
* rapid development. But be warned! If your Sails app will be accessed by *
* web browsers, you should _always_ enable CSRF protection before deploying *
* to production. *
* *
* To enable CSRF protection, set this to `true`. *
* *
* For more information, see: *
* https://sailsjs.com/docs/concepts/security/csrf *
* *
****************************************************************************/
// csrf: false
};

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: 'b7f0374251c4d79227067c286fe97ea5',
/***************************************************************************
* *
* 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'
};

37
package.json Normal file
View File

@ -0,0 +1,37 @@
{
"name": "roe-base",
"private": true,
"version": "0.0.0",
"description": "a Sails application",
"keywords": [],
"dependencies": {
"sails": "^1.0.2",
"grunt": "1.0.1",
"sails-hook-grunt": "^3.0.2",
"sails-hook-orm": "^2.0.0-16",
"sails-hook-sockets": "^1.4.0",
"@sailshq/connect-redis": "^3.2.1",
"@sailshq/socket.io-redis": "^5.2.0",
"@sailshq/lodash": "^3.10.3",
"async": "2.0.1"
},
"devDependencies": {
"@sailshq/eslint": "^4.19.3"
},
"scripts": {
"start": "NODE_ENV=production node app.js",
"test": "npm run lint && npm run custom-tests && echo 'Done.'",
"lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
"custom-tests": "echo \"(No other custom tests yet.)\" && echo"
},
"main": "app.js",
"repository": {
"type": "git",
"url": "git://github.com/vagrant/roe-base.git"
},
"author": "vagrant",
"license": "",
"engines": {
"node": ">=8.10"
}
}

54
tasks/config/babel.js Normal file
View File

@ -0,0 +1,54 @@
/**
* `tasks/config/babel`
*
* ---------------------------------------------------------------
*
* Transpile >=ES6 code for broader browser compatibility.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/babel.js
*
*/
module.exports = function(grunt) {
grunt.config.set('babel', {
dist: {
options: {
presets: [require('sails-hook-grunt/accessible/babel-preset-env')]
},
files: [
{
expand: true,
cwd: '.tmp/public',
src: ['js/**/*.js'],
dest: '.tmp/public'
}
]
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-babel --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-babel');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

52
tasks/config/clean.js Normal file
View File

@ -0,0 +1,52 @@
/**
* `tasks/config/clean`
*
* ---------------------------------------------------------------
*
* Remove generated files and folders.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/clean.js
*
*/
module.exports = function(grunt) {
grunt.config.set('clean', {
dev: ['.tmp/public/**'],
build: ['www'],
afterBuildProd: [
'www/concat',
'www/min',
'www/hash',
'www/js',
'www/styles',
'www/templates',
'www/dependencies'
]
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-clean --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-clean');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

56
tasks/config/coffee.js Normal file
View File

@ -0,0 +1,56 @@
/**
* `tasks/config/coffee`
*
* ---------------------------------------------------------------
*
* Compile CoffeeScript files located in `assets/js` into Javascript
* and generate new `.js` files in `.tmp/public/js`.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/coffee.js
*
*/
module.exports = function(grunt) {
grunt.config.set('coffee', {
dev: {
options: {
bare: true,
sourceMap: true,
sourceRoot: './'
},
files: [{
expand: true,
cwd: 'assets/js/',
src: ['**/*.coffee'],
dest: '.tmp/public/js/',
ext: '.js'
}]
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-coffee --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-coffee');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

50
tasks/config/concat.js Normal file
View File

@ -0,0 +1,50 @@
/**
* `tasks/config/concat`
*
* ---------------------------------------------------------------
*
* An intermediate step to generate monolithic files that can
* then be passed in to `uglify` and/or `cssmin` for minification.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/concat.js
*
*/
module.exports = function(grunt) {
grunt.config.set('concat', {
js: {
src: require('../pipeline').jsFilesToInject,
dest: '.tmp/public/concat/production.js'
},
css: {
src: require('../pipeline').cssFilesToInject,
dest: '.tmp/public/concat/production.css'
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-concat --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-concat');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

65
tasks/config/copy.js Normal file
View File

@ -0,0 +1,65 @@
/**
* `tasks/config/copy`
*
* ---------------------------------------------------------------
*
* Copy files and/or folders.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/copy.js
*
*/
module.exports = function(grunt) {
grunt.config.set('copy', {
dev: {
files: [{
expand: true,
cwd: './assets',
src: ['**/*.!(coffee|less)'],
dest: '.tmp/public'
}]
},
build: {
files: [{
expand: true,
cwd: '.tmp/public',
src: ['**/*'],
dest: 'www'
}]
},
beforeLinkBuildProd: {
files: [{
expand: true,
cwd: '.tmp/public/hash',
src: ['**/*'],
dest: '.tmp/public/dist'
}]
},
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-copy --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-copy');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

47
tasks/config/cssmin.js Normal file
View File

@ -0,0 +1,47 @@
/**
* `tasks/config/cssmin`
*
* ---------------------------------------------------------------
*
* Together with the `concat` task, this is the final step that minifies
* all CSS files from `assets/styles/` (and potentially your LESS importer
* file from `assets/styles/importer.less`)
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/cssmin.js
*
*/
module.exports = function(grunt) {
grunt.config.set('cssmin', {
dist: {
src: ['.tmp/public/concat/production.css'],
dest: '.tmp/public/min/production.min.css'
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-cssmin --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-cssmin');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

62
tasks/config/hash.js Normal file
View File

@ -0,0 +1,62 @@
/**
* `tasks/config/hash`
*
* ---------------------------------------------------------------
*
* Implement cache-busting for minified CSS and JavaScript files.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/hash.js
*
*/
module.exports = function(grunt) {
grunt.config.set('hash', {
options: {
mapping: '',
srcBasePath: '',
destBasePath: '',
flatten: false,
hashLength: 8,
hashFunction: function(source, encoding){
if (!source || !encoding) {
throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: '+require('util').inspect(source, {depth:null})+'\nencoding: '+require('util').inspect(encoding, {depth:null}));
}
return require('crypto').createHash('sha1').update(source, encoding).digest('hex');
}
},
js: {
src: '.tmp/public/min/*.js',
dest: '.tmp/public/hash/'
},
css: {
src: '.tmp/public/min/*.css',
dest: '.tmp/public/hash/'
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-hash --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-hash');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

62
tasks/config/jst.js Normal file
View File

@ -0,0 +1,62 @@
/**
* `tasks/config/jst`
*
* ---------------------------------------------------------------
*
* Precompile HTML templates using Underscore/Lodash notation.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/jst.js
*
*/
module.exports = function(grunt) {
grunt.config.set('jst', {
dev: {
// To use other sorts of templates, specify a regexp like the example below:
// options: {
// templateSettings: {
// interpolate: /\{\{(.+?)\}\}/g
// }
// },
// Note that the interpolate setting above is simply an example of overwriting lodash's
// default interpolation. If you want to parse templates with the default _.template behavior
// (i.e. using <div><%= this.id %></div>), there's no need to overwrite `templateSettings.interpolate`.
files: {
// e.g.
// 'relative/path/from/gruntfile/to/compiled/template/destination' : ['relative/path/to/sourcefiles/**/*.html']
'.tmp/public/jst.js': require('../pipeline').templateFilesToInject
}
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-jst --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-jst');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

50
tasks/config/less.js Normal file
View File

@ -0,0 +1,50 @@
/**
* `tasks/config/less`
*
* ---------------------------------------------------------------
*
* Compile your LESS files into a CSS stylesheet.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/less.js
*
*/
module.exports = function(grunt) {
grunt.config.set('less', {
dev: {
files: [{
expand: true,
cwd: 'assets/styles/',
src: ['importer.less'],
dest: '.tmp/public/styles/',
ext: '.css'
}]
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-less --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-less');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

View File

@ -0,0 +1,221 @@
/**
* `tasks/config/sails-linker`
*
* ---------------------------------------------------------------
*
* Automatically inject <script> tags and <link> tags into the specified
* specified HTML and/or EJS files. The specified delimiters (`startTag`
* and `endTag`) determine the insertion points.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/sails-linker.js
*
*/
module.exports = function(grunt) {
grunt.config.set('sails-linker', {
// ╦╔═╗╦ ╦╔═╗╔═╗╔═╗╦═╗╦╔═╗╔╦╗
// ║╠═╣╚╗╔╝╠═╣╚═╗║ ╠╦╝║╠═╝ ║
// ╚╝╩ ╩ ╚╝ ╩ ╩╚═╝╚═╝╩╚═╩╩ ╩
// ┌─ ┌─┐┬ ┬┌─┐┌┐┌┌┬┐ ┌─┐┬┌┬┐┌─┐ ┬┌─┐┬ ┬┌─┐┌─┐┌─┐┬─┐┬┌─┐┌┬┐ ─┐
// │─── │ │ │├┤ │││ │───└─┐│ ││├┤ │├─┤└┐┌┘├─┤└─┐│ ├┬┘│├─┘ │ ───│
// └─ └─┘┴─┘┴└─┘┘└┘ ┴ └─┘┴─┴┘└─┘ └┘┴ ┴ └┘ ┴ ┴└─┘└─┘┴└─┴┴ ┴ ─┘
devJs: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.ejs': require('../pipeline').jsFilesToInject
}
},
devJsBuild: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public',
// relative: true
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
// (but be note that this can break custom font URLs)
},
files: {
'.tmp/public/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.ejs': require('../pipeline').jsFilesToInject
}
},
prodJs: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/**/*.html': ['.tmp/public/min/production.min.js'],
'views/**/*.html': ['.tmp/public/min/production.min.js'],
'views/**/*.ejs': ['.tmp/public/min/production.min.js']
}
},
prodJsBuild: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public',
// relative: true
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
// (but be note that this can break custom font URLs)
},
files: {
'.tmp/public/**/*.html': ['.tmp/public/dist/*.js'],
'views/**/*.html': ['.tmp/public/dist/*.js'],
'views/**/*.ejs': ['.tmp/public/dist/*.js']
}
},
// ╔═╗╔╦╗╦ ╦╦ ╔═╗╔═╗╦ ╦╔═╗╔═╗╔╦╗╔═╗
// ╚═╗ ║ ╚╦╝║ ║╣ ╚═╗╠═╣║╣ ║╣ ║ ╚═╗
// ╚═╝ ╩ ╩ ╩═╝╚═╝╚═╝╩ ╩╚═╝╚═╝ ╩ ╚═╝
// ┌─ ┬┌┐┌┌─┐┬ ┬ ┬┌┬┐┬┌┐┌┌─┐ ╔═╗╔═╗╔═╗ ┬ ┌─┐┌─┐┌┬┐┌─┐┬┬ ┌─┐┌┬┐ ╦ ╔═╗╔═╗╔═╗ ─┐
// │─── │││││ │ │ │ │││││││ ┬ ║ ╚═╗╚═╗ ┌┼─ │ │ ││││├─┘││ ├┤ ││ ║ ║╣ ╚═╗╚═╗ ───│
// └─ ┴┘└┘└─┘┴─┘└─┘─┴┘┴┘└┘└─┘ ╚═╝╚═╝╚═╝ └┘ └─┘└─┘┴ ┴┴ ┴┴─┘└─┘─┴┘ ╩═╝╚═╝╚═╝╚═╝ ─┘
devStyles: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.ejs': require('../pipeline').cssFilesToInject
}
},
devStylesBuild: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public',
// relative: true
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
// (but be note that this can break custom font URLs)
},
files: {
'.tmp/public/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.ejs': require('../pipeline').cssFilesToInject
}
},
prodStyles: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/index.html': ['.tmp/public/min/production.min.css'],
'views/**/*.html': ['.tmp/public/min/production.min.css'],
'views/**/*.ejs': ['.tmp/public/min/production.min.css']
}
},
prodStylesBuild: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public',
// relative: true
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
// (but be note that this can break custom font URLs)
},
files: {
'.tmp/public/index.html': ['.tmp/public/dist/*.css'],
'views/**/*.html': ['.tmp/public/dist/*.css'],
'views/**/*.ejs': ['.tmp/public/dist/*.css']
}
},
// ╔═╗╦═╗╔═╗╔═╗╔═╗╔╦╗╔═╗╦╦ ╔═╗╔╦╗ ╦ ╦╔╦╗╔╦╗╦ ╔╦╗╔═╗╔╦╗╔═╗╦ ╔═╗╔╦╗╔═╗╔═╗
// ╠═╝╠╦╝║╣ ║ ║ ║║║║╠═╝║║ ║╣ ║║ ╠═╣ ║ ║║║║ ║ ║╣ ║║║╠═╝║ ╠═╣ ║ ║╣ ╚═╗
// ╩ ╩╚═╚═╝╚═╝╚═╝╩ ╩╩ ╩╩═╝╚═╝═╩╝ ╩ ╩ ╩ ╩ ╩╩═╝ ╩ ╚═╝╩ ╩╩ ╩═╝╩ ╩ ╩ ╚═╝╚═╝
// ┌─ ┌─┐┬ ┬┌─┐┌┐┌┌┬┐ ┌─┐┬┌┬┐┌─┐ ┬ ┌─┐┌┬┐┌─┐┌─┐┬ ┬ ┌┬┐┌─┐┌┬┐┌─┐┬ ┌─┐┌┬┐┌─┐┌─┐ ─┐
// │─── │ │ │├┤ │││ │───└─┐│ ││├┤ │ │ │ ││├─┤└─┐├─┤ │ ├┤ │││├─┘│ ├─┤ │ ├┤ └─┐ ───│
// └─ └─┘┴─┘┴└─┘┘└┘ ┴ └─┘┴─┴┘└─┘ ┴─┘└─┘─┴┘┴ ┴└─┘┴ ┴ ┴ └─┘┴ ┴┴ ┴─┘┴ ┴ ┴ └─┘└─┘ ─┘
clientSideTemplates: {
options: {
startTag: '<!--TEMPLATES-->',
endTag: '<!--TEMPLATES END-->',
fileTmpl: '<script type="text/javascript" src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/index.html': ['.tmp/public/jst.js'],
'views/**/*.html': ['.tmp/public/jst.js'],
'views/**/*.ejs': ['.tmp/public/jst.js']
}
},
clientSideTemplatesBuild: {
options: {
startTag: '<!--TEMPLATES-->',
endTag: '<!--TEMPLATES END-->',
fileTmpl: '<script type="text/javascript" src="%s"></script>',
appRoot: '.tmp/public',
// relative: true
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
// (but be note that this can break custom font URLs)
},
files: {
'.tmp/public/index.html': ['.tmp/public/jst.js'],
'views/**/*.html': ['.tmp/public/jst.js'],
'views/**/*.ejs': ['.tmp/public/jst.js']
}
},
});//</ grunt.config.set() >
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-sails-linker --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-sails-linker');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

49
tasks/config/sync.js Normal file
View File

@ -0,0 +1,49 @@
/**
* `tasks/config/sync`
*
* ---------------------------------------------------------------
*
* Synchronize files from the `assets` folder to `.tmp/public`,
* smashing anything that's already there.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/sync.js
*
*/
module.exports = function(grunt) {
grunt.config.set('sync', {
dev: {
files: [{
cwd: './assets',
src: ['**/*.!(coffee|less)'],
dest: '.tmp/public'
}]
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-sync --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-sync');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

62
tasks/config/uglify.js Normal file
View File

@ -0,0 +1,62 @@
/**
* `tasks/config/uglify`
*
* ---------------------------------------------------------------
*
* Minify client-side JavaScript files using UglifyES.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/uglify.js
*
*/
module.exports = function(grunt) {
grunt.config.set('uglify', {
dist: {
src: ['.tmp/public/concat/production.js'],
dest: '.tmp/public/min/production.min.js'
},
options: {
mangle: {
reserved: [
'AsyncFunction',
'SailsSocket',
'Promise',
'File',
'Location',
'RttcRefPlaceholder',
],
keep_fnames: true//eslint-disable-line
},
compress: {
keep_fnames: true//eslint-disable-line
}
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-uglify --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-uglify');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

56
tasks/config/watch.js Normal file
View File

@ -0,0 +1,56 @@
/**
* `tasks/config/watch`
*
* ---------------------------------------------------------------
*
* Run predefined tasks whenever certain files are added, changed or deleted.
*
* For more information, see:
* https://sailsjs.com/anatomy/tasks/config/watch.js
*
*/
module.exports = function(grunt) {
grunt.config.set('watch', {
assets: {
// Assets to watch:
files: [
'assets/**/*',
'tasks/pipeline.js',
'!**/node_modules/**'
],
// When assets are changed:
tasks: [
'syncAssets',
'linkAssets'
]
}
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This Grunt plugin is part of the default asset pipeline in Sails,
// so it's already been automatically loaded for you at this point.
//
// Of course, you can always remove this Grunt plugin altogether by
// deleting this file. But check this out: you can also use your
// _own_ custom version of this Grunt plugin.
//
// Here's how:
//
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-contrib-watch --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-contrib-watch');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
};

147
tasks/pipeline.js Normal file
View File

@ -0,0 +1,147 @@
/**
* tasks/pipeline.js
*
* The order in which your CSS, JavaScript, and client-side template files
* injected as <script> or <link> tags.
*
* > If you are not relying on automatic asset linking, then you can safely ignore this file.
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/pipeline.js
*/
// ██████╗ ██╗ █████╗ ██╗███╗ ██╗ ██████╗███████╗███████╗
// ██╔══██╗██║ ██╔══██╗██║████╗ ██║ ██╔════╝██╔════╝██╔════╝
// ██████╔╝██║ ███████║██║██╔██╗ ██║ ██║ ███████╗███████╗
// ██╔═══╝ ██║ ██╔══██║██║██║╚██╗██║ ██║ ╚════██║╚════██║
// ██║ ███████╗██║ ██║██║██║ ╚████║ ██╗╚██████╗███████║███████║
// ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝╚══════╝╚══════╝
//
// ███████╗██╗██╗ ███████╗███████╗
// ██╔════╝██║██║ ██╔════╝██╔════╝
// █████╗ ██║██║ █████╗ ███████╗
// ██╔══╝ ██║██║ ██╔══╝ ╚════██║
// ██║ ██║███████╗███████╗███████║
// ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
//
// CSS files to inject as <link> tags, in order.
//
// > Note: if you're using built-in LESS support with default settings,
// > you'll want to change `assets/styles/importer.less` instead.
//
var cssFilesToInject = [
// Bring in `.css` files for themes and style guides (e.g. Bootstrap, Foundation)
'dependencies/**/*.css',
// All of the rest of your custom `.css` files will be injected here,
// in no particular order. To customize the ordering, add additional
// items here, _above_ this one.
'styles/**/*.css'
];
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
// ██║ ██║ ██║█████╗ ██╔██╗ ██║ ██║█████╗███████╗██║██║ ██║█████╗
// ██║ ██║ ██║██╔══╝ ██║╚██╗██║ ██║╚════╝╚════██║██║██║ ██║██╔══╝
// ╚██████╗███████╗██║███████╗██║ ╚████║ ██║ ███████║██║██████╔╝███████╗
// ╚═════╝╚══════╝╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
//
// ██╗███████╗ ███████╗██╗██╗ ███████╗███████╗
// ██║██╔════╝ ██╔════╝██║██║ ██╔════╝██╔════╝
// ██║███████╗ █████╗ ██║██║ █████╗ ███████╗
// ██ ██║╚════██║ ██╔══╝ ██║██║ ██╔══╝ ╚════██║
// ██╗╚█████╔╝███████║ ██║ ██║███████╗███████╗███████║
// ╚═╝ ╚════╝ ╚══════╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
//
// Client-side javascript files to inject as <script> tags, in order.
//
var jsFilesToInject = [
// Load `sails.io` before everything else.
'dependencies/sails.io.js',
// Bring in `.js` files for any other client-side JavaScript dependencies.
// (e.g. Lodash, Vue.js, jQuery, Bootstrap, Ember, Angular, etc.)
// > Be sure to list dependencies that depend on each other in the right order!
'dependencies/**/*.js',
// All of the rest of your custom client-side js files will be injected here,
// in no particular order. To customize the ordering, add additional items
// here, _above_ this one.
'js/**/*.js'
];
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
// ██║ ██║ ██║█████╗ ██╔██╗ ██║ ██║█████╗███████╗██║██║ ██║█████╗
// ██║ ██║ ██║██╔══╝ ██║╚██╗██║ ██║╚════╝╚════██║██║██║ ██║██╔══╝
// ╚██████╗███████╗██║███████╗██║ ╚████║ ██║ ███████║██║██████╔╝███████╗
// ╚═════╝╚══════╝╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
//
// ████████╗███████╗███╗ ███╗██████╗ ██╗ █████╗ ████████╗███████╗███████╗
// ╚══██╔══╝██╔════╝████╗ ████║██╔══██╗██║ ██╔══██╗╚══██╔══╝██╔════╝██╔════╝
// ██║ █████╗ ██╔████╔██║██████╔╝██║ ███████║ ██║ █████╗ ███████╗
// ██║ ██╔══╝ ██║╚██╔╝██║██╔═══╝ ██║ ██╔══██║ ██║ ██╔══╝ ╚════██║
// ██║ ███████╗██║ ╚═╝ ██║██║ ███████╗██║ ██║ ██║ ███████╗███████║
// ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝
//
// Client-side HTML templates to precompile and inject as a single <script> tag.
// (The ordering of this array shouldn't matter.)
//
// > By default, Sails uses JST (~=lodash/underscore) templates and precompiles
// > them into functions for you. If you want to use handlebars, pug, dust, etc.,
// > with the asset linker, no problem-- you'll just want to make sure the precompiled
// > templates get spit out to the same file. For information on customizing and
// > installing your own Grunt tasks or using a different build pipeline, be sure
// > to check out:
// > https://sailsjs.com/docs/concepts/assets/task-automation
//
var templateFilesToInject = [
'templates/**/*.html'
];
// ███╗ ███╗██╗███████╗ ██████╗ ███████╗███████╗████████╗██╗ ██╗██████╗
// ████╗ ████║██║██╔════╝██╔════╝ ██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
// ██╔████╔██║██║███████╗██║ ███████╗█████╗ ██║ ██║ ██║██████╔╝
// ██║╚██╔╝██║██║╚════██║██║ ╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝
// ██║ ╚═╝ ██║██║███████║╚██████╗██╗ ███████║███████╗ ██║ ╚██████╔╝██║
// ╚═╝ ╚═╝╚═╝╚══════╝ ╚═════╝╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝
//
// The following code exists to parse the arrays of glob expressions above, and
// then expose them via `module.exports`. **You should not need to change any of
// the code below, unless you are modifying the default asset pipeline.**
// Default path for public folder (see documentation on sailsjs.com for more information)
var tmpPath = '.tmp/public/';
// Prefix relative paths to source files so they point to the proper locations
// (i.e. where the other Grunt tasks spit them out, or in some cases, where
// they reside in the first place)
module.exports.cssFilesToInject = cssFilesToInject.map((cssPath)=>{
// If we're ignoring the file, make sure the ! is at the beginning of the path
if (cssPath[0] === '!') {
return require('path').join('!' + tmpPath, cssPath.substr(1));
}
return require('path').join(tmpPath, cssPath);
});
module.exports.jsFilesToInject = jsFilesToInject.map((jsPath)=>{
// If we're ignoring the file, make sure the ! is at the beginning of the path
if (jsPath[0] === '!') {
return require('path').join('!' + tmpPath, jsPath.substr(1));
}
return require('path').join(tmpPath, jsPath);
});
module.exports.templateFilesToInject = templateFilesToInject.map((tplPath)=>{
// If we're ignoring the file, make sure the ! is at the beginning of the path
if (tplPath[0] === '!') {
return require('path').join('!assets/', tplPath.substr(1));
}
return require('path').join('assets/', tplPath);
});

22
tasks/register/build.js Normal file
View File

@ -0,0 +1,22 @@
/**
* `tasks/register/build.js`
*
* ---------------------------------------------------------------
*
* This Grunt tasklist will be executed if you run `sails www` or
* `grunt build` in a development environment.
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/build.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('build', [
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
'compileAssets',
// 'babel', //« uncomment to ALSO transpile during development (for broader browser compat.)
'linkAssetsBuild',
'clean:build',
'copy:build'
]);
};

View File

@ -0,0 +1,30 @@
/**
* `tasks/register/buildProd.js`
*
* ---------------------------------------------------------------
*
* This Grunt tasklist will be executed instead of `build` if you
* run `sails www` in a production environment, e.g.:
* `NODE_ENV=production sails www`
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/build-prod.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('buildProd', [
'polyfill:prod', //« Remove this to skip transpilation in production (not recommended)
'compileAssets',
'babel', //« Remove this to skip transpilation in production (not recommended)
'concat',
'uglify',
'cssmin',
'hash',//« Cache-busting
'copy:beforeLinkBuildProd',//« For prettier URLs after cache-busting
'linkAssetsBuildProd',
'clean:build',
'copy:build',
'clean:afterBuildProd'
]);
};

View File

@ -0,0 +1,18 @@
/**
* `tasks/register/compileAssets.js`
*
* ---------------------------------------------------------------
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/compile-assets.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('compileAssets', [
'clean:dev',
'jst:dev',
'less:dev',
'copy:dev',
'coffee:dev'
]);
};

27
tasks/register/default.js Normal file
View File

@ -0,0 +1,27 @@
/**
* `tasks/register/default.js`
*
* ---------------------------------------------------------------
*
* This is the default Grunt tasklist that will be executed if you
* run `grunt` in the top level directory of your app. It is also
* called automatically when you start Sails in development mode using
* `sails lift` or `node app` in a development environment.
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/default.js
*
*/
module.exports = function (grunt) {
grunt.registerTask('default', [
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
'compileAssets',
// 'babel', //« uncomment to ALSO transpile during development (for broader browser compat.)
'linkAssets',
'watch'
]);
};

View File

@ -0,0 +1,16 @@
/**
* `tasks/register/linkAssets.js`
*
* ---------------------------------------------------------------
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/link-assets.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('linkAssets', [
'sails-linker:devJs',
'sails-linker:devStyles',
'sails-linker:clientSideTemplates'
]);
};

View File

@ -0,0 +1,16 @@
/**
* `tasks/register/linkAssetsBuild.js`
*
* ---------------------------------------------------------------
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/link-assets-build.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('linkAssetsBuild', [
'sails-linker:devJsBuild',
'sails-linker:devStylesBuild',
'sails-linker:clientSideTemplatesBuild'
]);
};

View File

@ -0,0 +1,16 @@
/**
* `tasks/register/linkAssetsBuildProd.js`
*
* ---------------------------------------------------------------
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/link-assets-build-prod.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('linkAssetsBuildProd', [
'sails-linker:prodJsBuild',
'sails-linker:prodStylesBuild',
'sails-linker:clientSideTemplatesBuild'
]);
};

View File

@ -0,0 +1,28 @@
/**
* `tasks/register/polyfill.js`
*
* ---------------------------------------------------------------
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/polyfill.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('polyfill:prod', 'Add the polyfill file to the top of the list of files to concatenate', ()=>{
grunt.config.set('concat.js.src', [require('sails-hook-grunt/accessible/babel-polyfill')].concat(grunt.config.get('concat.js.src')));
});
grunt.registerTask('polyfill:dev', 'Add the polyfill file to the top of the list of files to copy and link', ()=>{
grunt.config.set('copy.dev.files', grunt.config.get('copy.dev.files').concat({
expand: true,
cwd: require('path').dirname(require('sails-hook-grunt/accessible/babel-polyfill')),
src: require('path').basename(require('sails-hook-grunt/accessible/babel-polyfill')),
dest: '.tmp/public/polyfill'
}));
var devLinkFiles = grunt.config.get('sails-linker.devJs.files');
grunt.config.set('sails-linker.devJs.files', Object.keys(devLinkFiles).reduce((linkerConfigSoFar, glob)=>{
linkerConfigSoFar[glob] = ['.tmp/public/polyfill/polyfill.min.js'].concat(devLinkFiles[glob]);
return linkerConfigSoFar;
}, {}));
});
};

27
tasks/register/prod.js Normal file
View File

@ -0,0 +1,27 @@
/**
* `tasks/register/prod.js`
*
* ---------------------------------------------------------------
*
* This Grunt tasklist will be executed instead of `default` when
* your Sails app is lifted in a production environment (e.g. using
* `NODE_ENV=production node app`).
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/prod.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('prod', [
'polyfill:prod', //« Remove this to skip transpilation in production (not recommended)
'compileAssets',
'babel', //« Remove this to skip transpilation in production (not recommended)
'concat',
'uglify',
'cssmin',
'sails-linker:prodJs',
'sails-linker:prodStyles',
'sails-linker:clientSideTemplates',
]);
};

View File

@ -0,0 +1,17 @@
/**
* `tasks/register/syncAssets.js`
*
* ---------------------------------------------------------------
*
* For more information see:
* https://sailsjs.com/anatomy/tasks/register/sync-assets.js
*
*/
module.exports = function(grunt) {
grunt.registerTask('syncAssets', [
'jst:dev',
'less:dev',
'sync:dev',
'coffee:dev'
]);
};

21
views/.eslintrc Normal file
View File

@ -0,0 +1,21 @@
{
// ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐ ┌─┐┬ ┬┌─┐┬─┐┬─┐┬┌┬┐┌─┐
// ║╣ ╚═╗║ ║║║║ ║ ├┬┘│ │ │└┐┌┘├┤ ├┬┘├┬┘│ ││├┤
// o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘ └─┘ └┘ └─┘┴└─┴└─┴─┴┘└─┘
// ┌─ ┌─┐┌─┐┬─┐ ┬┌┐┌┬ ┬┌┐┌┌─┐ ┌─┐┌─┐┬─┐┬┌─┐┌┬┐ ┌┬┐┌─┐┌─┐┌─┐ ─┐
// │ ├┤ │ │├┬┘ │││││ ││││├┤ └─┐│ ├┬┘│├─┘ │ │ ├─┤│ ┬└─┐ │
// └─ └ └─┘┴└─ ┴┘└┘┴─┘┴┘└┘└─┘ └─┘└─┘┴└─┴┴ ┴ ┴ ┴ ┴└─┘└─┘ ─┘
// > An .eslintrc configuration override for use in the `views/` directory.
//
// (This works just like assets/.eslintrc, with one minor addition)
//
// For more information see:
// https://sailsjs.com/anatomy/views/.eslintrc
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"extends": [
"../assets/.eslintrc"
],
"rules": {
"eol-last": [0]
}
}

64
views/404.ejs Normal file

File diff suppressed because one or more lines are too long

63
views/500.ejs Normal file

File diff suppressed because one or more lines are too long

110
views/layouts/layout.ejs Normal file
View File

@ -0,0 +1,110 @@
<!DOCTYPE html>
<html>
<head>
<title>New Sails App</title>
<!-- Viewport mobile tag for sensible mobile support -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--
Stylesheets and Preprocessors
==============================
You can always bring in CSS files manually with `<link>` tags, or asynchronously
using a solution like AMD (RequireJS). Or, if you like, you can take advantage
of Sails' conventional asset pipeline (boilerplate Gruntfile).
By default, stylesheets from your `assets/styles` folder are included
here automatically (between STYLES and STYLES END). Both CSS (.css) and LESS (.less)
are supported. In production, your styles will be minified and concatenated into
a single file.
To customize any part of the built-in behavior, just edit `tasks/pipeline.js`.
For example, here are a few things you could do:
+ Change the order of your CSS files
+ Import stylesheets from other directories
+ Use a different or additional preprocessor, like SASS, SCSS or Stylus
-->
<!--STYLES-->
<link rel="stylesheet" href="/styles/importer.css">
<!--STYLES END-->
</head>
<body>
<%- body %>
<!--
Client-side Templates
========================
HTML templates are important prerequisites of modern, rich client applications.
To work their magic, frameworks like React, Vue.js, Angular, Ember, and Backbone
require that you load these templates client-side.
By default, your Gruntfile is configured to automatically load and precompile
client-side JST templates in your `assets/templates` folder, then
include them here automatically (between TEMPLATES and TEMPLATES END).
To customize this behavior to fit your needs, just edit `tasks/pipeline.js`.
For example, here are a few things you could do:
+ Import templates from other directories
+ Use a different view engine (handlebars, dust, pug/jade, etc.)
+ Internationalize your client-side templates using a server-side
stringfile before they're served.
-->
<!--TEMPLATES-->
<!--TEMPLATES END-->
<!--
Server-side View Locals
========================
Sometimes, it's convenient to get access to your server-side view locals from
client-side JavaScript. This can improve page load times, remove the need for
extra AJAX requests, and make your client-side code easier to understand and
to maintain. Sails provides a simple mechanism for accessing dynamic view
locals: the "exposeLocalsToBrowser()" view partial.
For more information on using this built-in feature, see:
https://sailsjs.com/docs/concepts/views/locals#?escaping-untrusted-data-using-exposelocalstobrowser
-->
<!--
Client-side Javascript
========================
You can always bring in JS files manually with `script` tags, or asynchronously
on the client using a solution like AMD (RequireJS). Or, if you like, you can
take advantage of Sails' conventional asset pipeline (boilerplate Gruntfile).
By default, files in your `assets/js` folder are included here
automatically (between SCRIPTS and SCRIPTS END). Both JavaScript (.js) and
CoffeeScript (.coffee) are supported. In production, your scripts will be minified
and concatenated into a single file.
To customize any part of the built-in behavior, just edit `tasks/pipeline.js`.
For example, here are a few things you could do:
+ Change the order of your scripts
+ Import scripts from other directories
+ Use a different preprocessor, like TypeScript
-->
<!--SCRIPTS-->
<script src="/dependencies/sails.io.js"></script>
<!--SCRIPTS END-->
</body>
</html>

78
views/pages/homepage.ejs Normal file

File diff suppressed because one or more lines are too long