├── .gitignore ├── .sailsrc ├── Gruntfile.js ├── README.md ├── api ├── policies │ └── sessionAuth.js └── responses │ ├── badRequest.js │ ├── forbidden.js │ ├── notFound.js │ └── serverError.js ├── app.js ├── assets ├── css │ ├── .gitkeep │ └── app.css ├── img │ └── .gitkeep ├── index-async.html ├── index-async.html.template ├── index.html ├── js │ ├── app.js │ ├── controllers.js │ ├── directives.js │ ├── filters.js │ └── services.js ├── lib │ └── angular │ │ ├── angular-animate.js │ │ ├── angular-animate.min.js │ │ ├── angular-animate.min.js.map │ │ ├── angular-cookies.js │ │ ├── angular-cookies.min.js │ │ ├── angular-cookies.min.js.map │ │ ├── angular-csp.css │ │ ├── angular-loader.js │ │ ├── angular-loader.min.js │ │ ├── angular-loader.min.js.map │ │ ├── angular-resource.js │ │ ├── angular-resource.min.js │ │ ├── angular-resource.min.js.map │ │ ├── angular-route.js │ │ ├── angular-route.min.js │ │ ├── angular-route.min.js.map │ │ ├── angular-sanitize.js │ │ ├── angular-sanitize.min.js │ │ ├── angular-sanitize.min.js.map │ │ ├── angular-scenario.js │ │ ├── angular-touch.js │ │ ├── angular-touch.min.js │ │ ├── angular-touch.min.js.map │ │ ├── angular.js │ │ ├── angular.min.js │ │ ├── angular.min.js.gzip │ │ ├── angular.min.js.map │ │ ├── errors.json │ │ ├── i18n │ │ ├── angular-locale_af-na.js │ │ ├── angular-locale_af-za.js │ │ ├── angular-locale_af.js │ │ ├── angular-locale_am-et.js │ │ ├── angular-locale_am.js │ │ ├── angular-locale_ar-001.js │ │ ├── angular-locale_ar-ae.js │ │ ├── angular-locale_ar-bh.js │ │ ├── angular-locale_ar-dz.js │ │ ├── angular-locale_ar-eg.js │ │ ├── angular-locale_ar-iq.js │ │ ├── angular-locale_ar-jo.js │ │ ├── angular-locale_ar-kw.js │ │ ├── angular-locale_ar-lb.js │ │ ├── angular-locale_ar-ly.js │ │ ├── angular-locale_ar-ma.js │ │ ├── angular-locale_ar-om.js │ │ ├── angular-locale_ar-qa.js │ │ ├── angular-locale_ar-sa.js │ │ ├── angular-locale_ar-sd.js │ │ ├── angular-locale_ar-sy.js │ │ ├── angular-locale_ar-tn.js │ │ ├── angular-locale_ar-ye.js │ │ ├── angular-locale_ar.js │ │ ├── angular-locale_bg-bg.js │ │ ├── angular-locale_bg.js │ │ ├── angular-locale_bn-bd.js │ │ ├── angular-locale_bn-in.js │ │ ├── angular-locale_bn.js │ │ ├── angular-locale_ca-ad.js │ │ ├── angular-locale_ca-es.js │ │ ├── angular-locale_ca.js │ │ ├── angular-locale_cs-cz.js │ │ ├── angular-locale_cs.js │ │ ├── angular-locale_da-dk.js │ │ ├── angular-locale_da.js │ │ ├── angular-locale_de-at.js │ │ ├── angular-locale_de-be.js │ │ ├── angular-locale_de-ch.js │ │ ├── angular-locale_de-de.js │ │ ├── angular-locale_de-li.js │ │ ├── angular-locale_de-lu.js │ │ ├── angular-locale_de.js │ │ ├── angular-locale_el-cy.js │ │ ├── angular-locale_el-gr.js │ │ ├── angular-locale_el.js │ │ ├── angular-locale_en-as.js │ │ ├── angular-locale_en-au.js │ │ ├── angular-locale_en-bb.js │ │ ├── angular-locale_en-be.js │ │ ├── angular-locale_en-bm.js │ │ ├── angular-locale_en-bw.js │ │ ├── angular-locale_en-bz.js │ │ ├── angular-locale_en-ca.js │ │ ├── angular-locale_en-dsrt-us.js │ │ ├── angular-locale_en-dsrt.js │ │ ├── angular-locale_en-fm.js │ │ ├── angular-locale_en-gb.js │ │ ├── angular-locale_en-gu.js │ │ ├── angular-locale_en-gy.js │ │ ├── angular-locale_en-hk.js │ │ ├── angular-locale_en-ie.js │ │ ├── angular-locale_en-in.js │ │ ├── angular-locale_en-iso.js │ │ ├── angular-locale_en-jm.js │ │ ├── angular-locale_en-mh.js │ │ ├── angular-locale_en-mp.js │ │ ├── angular-locale_en-mt.js │ │ ├── angular-locale_en-mu.js │ │ ├── angular-locale_en-na.js │ │ ├── angular-locale_en-nz.js │ │ ├── angular-locale_en-ph.js │ │ ├── angular-locale_en-pk.js │ │ ├── angular-locale_en-pr.js │ │ ├── angular-locale_en-pw.js │ │ ├── angular-locale_en-sg.js │ │ ├── angular-locale_en-tc.js │ │ ├── angular-locale_en-tt.js │ │ ├── angular-locale_en-um.js │ │ ├── angular-locale_en-us.js │ │ ├── angular-locale_en-vg.js │ │ ├── angular-locale_en-vi.js │ │ ├── angular-locale_en-za.js │ │ ├── angular-locale_en-zw.js │ │ ├── angular-locale_en.js │ │ ├── angular-locale_es-419.js │ │ ├── angular-locale_es-ar.js │ │ ├── angular-locale_es-bo.js │ │ ├── angular-locale_es-cl.js │ │ ├── angular-locale_es-co.js │ │ ├── angular-locale_es-cr.js │ │ ├── angular-locale_es-do.js │ │ ├── angular-locale_es-ea.js │ │ ├── angular-locale_es-ec.js │ │ ├── angular-locale_es-es.js │ │ ├── angular-locale_es-gq.js │ │ ├── angular-locale_es-gt.js │ │ ├── angular-locale_es-hn.js │ │ ├── angular-locale_es-ic.js │ │ ├── angular-locale_es-mx.js │ │ ├── angular-locale_es-ni.js │ │ ├── angular-locale_es-pa.js │ │ ├── angular-locale_es-pe.js │ │ ├── angular-locale_es-pr.js │ │ ├── angular-locale_es-py.js │ │ ├── angular-locale_es-sv.js │ │ ├── angular-locale_es-us.js │ │ ├── angular-locale_es-uy.js │ │ ├── angular-locale_es-ve.js │ │ ├── angular-locale_es.js │ │ ├── angular-locale_et-ee.js │ │ ├── angular-locale_et.js │ │ ├── angular-locale_eu-es.js │ │ ├── angular-locale_eu.js │ │ ├── angular-locale_fa-af.js │ │ ├── angular-locale_fa-ir.js │ │ ├── angular-locale_fa.js │ │ ├── angular-locale_fi-fi.js │ │ ├── angular-locale_fi.js │ │ ├── angular-locale_fil-ph.js │ │ ├── angular-locale_fil.js │ │ ├── angular-locale_fr-be.js │ │ ├── angular-locale_fr-bf.js │ │ ├── angular-locale_fr-bi.js │ │ ├── angular-locale_fr-bj.js │ │ ├── angular-locale_fr-bl.js │ │ ├── angular-locale_fr-ca.js │ │ ├── angular-locale_fr-cd.js │ │ ├── angular-locale_fr-cf.js │ │ ├── angular-locale_fr-cg.js │ │ ├── angular-locale_fr-ch.js │ │ ├── angular-locale_fr-ci.js │ │ ├── angular-locale_fr-cm.js │ │ ├── angular-locale_fr-dj.js │ │ ├── angular-locale_fr-fr.js │ │ ├── angular-locale_fr-ga.js │ │ ├── angular-locale_fr-gf.js │ │ ├── angular-locale_fr-gn.js │ │ ├── angular-locale_fr-gp.js │ │ ├── angular-locale_fr-gq.js │ │ ├── angular-locale_fr-km.js │ │ ├── angular-locale_fr-lu.js │ │ ├── angular-locale_fr-mc.js │ │ ├── angular-locale_fr-mf.js │ │ ├── angular-locale_fr-mg.js │ │ ├── angular-locale_fr-ml.js │ │ ├── angular-locale_fr-mq.js │ │ ├── angular-locale_fr-ne.js │ │ ├── angular-locale_fr-re.js │ │ ├── angular-locale_fr-yt.js │ │ ├── angular-locale_fr.js │ │ ├── angular-locale_gl-es.js │ │ ├── angular-locale_gl.js │ │ ├── angular-locale_gsw-ch.js │ │ ├── angular-locale_gsw.js │ │ ├── angular-locale_gu-in.js │ │ ├── angular-locale_gu.js │ │ ├── angular-locale_he-il.js │ │ ├── angular-locale_he.js │ │ ├── angular-locale_hi-in.js │ │ ├── angular-locale_hi.js │ │ ├── angular-locale_hr-hr.js │ │ ├── angular-locale_hr.js │ │ ├── angular-locale_hu-hu.js │ │ ├── angular-locale_hu.js │ │ ├── angular-locale_id-id.js │ │ ├── angular-locale_id.js │ │ ├── angular-locale_in.js │ │ ├── angular-locale_is-is.js │ │ ├── angular-locale_is.js │ │ ├── angular-locale_it-it.js │ │ ├── angular-locale_it-sm.js │ │ ├── angular-locale_it.js │ │ ├── angular-locale_iw.js │ │ ├── angular-locale_ja-jp.js │ │ ├── angular-locale_ja.js │ │ ├── angular-locale_kn-in.js │ │ ├── angular-locale_kn.js │ │ ├── angular-locale_ko-kr.js │ │ ├── angular-locale_ko.js │ │ ├── angular-locale_ln-cd.js │ │ ├── angular-locale_ln.js │ │ ├── angular-locale_lt-lt.js │ │ ├── angular-locale_lt.js │ │ ├── angular-locale_lv-lv.js │ │ ├── angular-locale_lv.js │ │ ├── angular-locale_ml-in.js │ │ ├── angular-locale_ml.js │ │ ├── angular-locale_mr-in.js │ │ ├── angular-locale_mr.js │ │ ├── angular-locale_ms-my.js │ │ ├── angular-locale_ms.js │ │ ├── angular-locale_mt-mt.js │ │ ├── angular-locale_mt.js │ │ ├── angular-locale_nl-cw.js │ │ ├── angular-locale_nl-nl.js │ │ ├── angular-locale_nl-sx.js │ │ ├── angular-locale_nl.js │ │ ├── angular-locale_no.js │ │ ├── angular-locale_or-in.js │ │ ├── angular-locale_or.js │ │ ├── angular-locale_pl-pl.js │ │ ├── angular-locale_pl.js │ │ ├── angular-locale_pt-br.js │ │ ├── angular-locale_pt-pt.js │ │ ├── angular-locale_pt.js │ │ ├── angular-locale_ro-ro.js │ │ ├── angular-locale_ro.js │ │ ├── angular-locale_ru-ru.js │ │ ├── angular-locale_ru.js │ │ ├── angular-locale_sk-sk.js │ │ ├── angular-locale_sk.js │ │ ├── angular-locale_sl-si.js │ │ ├── angular-locale_sl.js │ │ ├── angular-locale_sq-al.js │ │ ├── angular-locale_sq.js │ │ ├── angular-locale_sr-cyrl-rs.js │ │ ├── angular-locale_sr-latn-rs.js │ │ ├── angular-locale_sr.js │ │ ├── angular-locale_sv-se.js │ │ ├── angular-locale_sv.js │ │ ├── angular-locale_sw-tz.js │ │ ├── angular-locale_sw.js │ │ ├── angular-locale_ta-in.js │ │ ├── angular-locale_ta.js │ │ ├── angular-locale_te-in.js │ │ ├── angular-locale_te.js │ │ ├── angular-locale_th-th.js │ │ ├── angular-locale_th.js │ │ ├── angular-locale_tl.js │ │ ├── angular-locale_tr-tr.js │ │ ├── angular-locale_tr.js │ │ ├── angular-locale_uk-ua.js │ │ ├── angular-locale_uk.js │ │ ├── angular-locale_ur-pk.js │ │ ├── angular-locale_ur.js │ │ ├── angular-locale_vi-vn.js │ │ ├── angular-locale_vi.js │ │ ├── angular-locale_zh-cn.js │ │ ├── angular-locale_zh-hans-cn.js │ │ ├── angular-locale_zh-hk.js │ │ ├── angular-locale_zh-tw.js │ │ ├── angular-locale_zh.js │ │ ├── angular-locale_zu-za.js │ │ └── angular-locale_zu.js │ │ ├── version.json │ │ └── version.txt └── partials │ ├── .gitkeep │ ├── partial1.html │ └── partial2.html ├── config ├── blueprints.js ├── bootstrap.js ├── connections.js ├── cors.js ├── csrf.js ├── express.js ├── globals.js ├── i18n.js ├── locales │ ├── _README.md │ ├── de.json │ ├── en.json │ ├── es.json │ └── fr.json ├── log.js ├── models.js ├── policies.js ├── routes.js ├── session.js ├── sockets.js └── views.js ├── package.json ├── tasks ├── config │ ├── clean.js │ ├── coffee.js │ ├── concat.js │ ├── copy.js │ ├── cssmin.js │ ├── jst.js │ ├── less.js │ ├── sails-linker.js │ ├── sync.js │ ├── uglify.js │ └── watch.js ├── register │ ├── build.js │ ├── buildProd.js │ ├── compileAssets.js │ ├── default.js │ ├── linkAssets.js │ ├── linkAssetsBuild.js │ ├── linkAssetsBuildProd.js │ ├── prod.js │ └── syncAssets.js └── values │ └── injectedFiles.js └── views ├── 403.ejs ├── 404.ejs ├── 500.ejs ├── homepage.ejs └── layout.ejs /.sailsrc: -------------------------------------------------------------------------------- 1 | { 2 | "generators": { 3 | "modules": {} 4 | } 5 | } -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | var includeAll = require('sails/node_modules/include-all') 2 | , path = require('path'); 3 | 4 | /** 5 | * Gruntfile 6 | * 7 | * By default, the Gruntfile in new Sails projects comes with a `linker` 8 | * task, which will automatically inject client-side scripts, styles, and templates 9 | * from your `assets` folder into specific regions of certain EJS and HTML files 10 | * specified below. This behavior is completely optional, but here for convenience. 11 | * 12 | * At the top part of this file, you'll find a few of the most commonly 13 | * configured options, but Sails' integration with Grunt is also fully 14 | * customizable. If you'd like to work with your assets differently 15 | * you can change this file to do anything you like! 16 | * 17 | * More information on using Grunt to work with static assets: 18 | * http://gruntjs.com/configuring-tasks 19 | */ 20 | 21 | module.exports = function(grunt) { 22 | 23 | 24 | 25 | configureGruntfile(); 26 | 27 | /** 28 | * Load CommonJS submodules from the specified 29 | * relative path. 30 | * 31 | * @return {Object} 32 | */ 33 | function loadTasks (relPath) { 34 | return includeAll({ 35 | dirname: path.resolve(__dirname, relPath), 36 | filter: /(.+)\.js$/ 37 | }); 38 | } 39 | 40 | /** 41 | * Invokes the config function for the task config and register definitions. 42 | * Make sure to pass in grunt. 43 | * 44 | * @param {Object} tasks [Grunt object that each task will need] 45 | */ 46 | function invokeConfigFn (tasks) { 47 | for (var taskName in tasks) { 48 | if (tasks.hasOwnProperty(taskName)) { 49 | tasks[taskName](grunt); 50 | } 51 | } 52 | } 53 | 54 | /** 55 | * Configure the gruntfile. 56 | */ 57 | function configureGruntfile () { 58 | var taskConfigurations = loadTasks('./tasks/config'), 59 | registerDefinitions = loadTasks('./tasks/register'); 60 | 61 | invokeConfigFn(taskConfigurations); 62 | invokeConfigFn(registerDefinitions); 63 | } 64 | }; 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular on Sails 2 | 3 | Just a plain 'ol skeleton v0.10 Sails app with [Angular Seed](https://github.com/angular/angular-seed) in the assets folder, layout.ejs and homepage.ejs. 4 | -------------------------------------------------------------------------------- /api/policies/sessionAuth.js: -------------------------------------------------------------------------------- 1 | /** 2 | * sessionAuth 3 | * 4 | * @module :: Policy 5 | * @description :: Simple policy to allow any authenticated user 6 | * Assumes that your login action in one of your controllers sets `req.session.authenticated = true;` 7 | * @docs :: http://sailsjs.org/#!documentation/policies 8 | * 9 | */ 10 | module.exports = function(req, res, next) { 11 | 12 | // User is allowed, proceed to the next policy, 13 | // or if this is the last policy, the controller 14 | if (req.session.authenticated) { 15 | return next(); 16 | } 17 | 18 | // User is not allowed 19 | // (default res.forbidden() behavior can be overridden in `config/403.js`) 20 | return res.forbidden('You are not permitted to perform this action.'); 21 | }; 22 | -------------------------------------------------------------------------------- /api/responses/forbidden.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 403 (Forbidden) Handler 3 | * 4 | * Usage: 5 | * return res.forbidden('Access denied.'); 6 | * 7 | * @param {String|Object|Array} message 8 | * optional message to inject into view locals or JSON response 9 | * 10 | */ 11 | 12 | module.exports = function forbidden(message) { 13 | 14 | // Get access to `req` and `res` 15 | var req = this.req; 16 | var res = this.res; 17 | 18 | var viewFilePath = '403'; 19 | var statusCode = 403; 20 | 21 | var result = { 22 | status: statusCode 23 | }; 24 | 25 | // Optional message 26 | if (message) { 27 | result.message = message; 28 | } 29 | 30 | // If the user-agent wants a JSON response, send json 31 | if (req.wantsJSON) { 32 | return res.json(result, result.status); 33 | } 34 | 35 | // Set status code and view locals 36 | res.status(result.status); 37 | for (var key in result) { 38 | res.locals[key] = result[key]; 39 | } 40 | // And render view 41 | res.render(viewFilePath, result, function(err) { 42 | // If the view doesn't exist, or an error occured, send json 43 | if (err) { 44 | return res.json(result, result.status); 45 | } 46 | 47 | // Otherwise, serve the `views/403.*` page 48 | res.render(viewFilePath); 49 | }); 50 | }; 51 | -------------------------------------------------------------------------------- /api/responses/notFound.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 404 (Not Found) Handler 3 | * 4 | * Usage: 5 | * return res.notFound(); 6 | * 7 | * NOTE: 8 | * If no user-defined route, blueprint route, or static file matches 9 | * the requested URL, Sails will call `res.notFound()`. 10 | */ 11 | 12 | module.exports = function notFound() { 13 | 14 | // Get access to `req` and `res` 15 | var req = this.req; 16 | var res = this.res; 17 | 18 | var viewFilePath = '404'; 19 | var statusCode = 404; 20 | var result = { 21 | status: statusCode 22 | }; 23 | 24 | // If the user-agent wants a JSON response, send json 25 | if (req.wantsJSON) { 26 | return res.json(result, result.status); 27 | } 28 | 29 | res.status(result.status); 30 | res.render(viewFilePath, function(err) { 31 | // If the view doesn't exist, or an error occured, send json 32 | if (err) { 33 | return res.json(result, result.status); 34 | } 35 | 36 | // Otherwise, serve the `views/404.*` page 37 | res.render(viewFilePath); 38 | }); 39 | }; 40 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * app.js 3 | * 4 | * Use `app.js` to run your app without `sails lift`. 5 | * To start the server, run: `node app.js`. 6 | * 7 | * This is handy in situations where the sails CLI is not relevant or useful. 8 | * 9 | * For example: 10 | * => `node app.js` 11 | * => `forever start app.js` 12 | * => `node debug app.js` 13 | * => `modulus deploy` 14 | * => `heroku scale` 15 | * 16 | * 17 | * The same command-line arguments are supported, e.g.: 18 | * `node app.js --silent --port=80 --prod` 19 | */ 20 | 21 | // Ensure a "sails" can be located: 22 | var sails; 23 | try { 24 | sails = require('sails'); 25 | } 26 | catch (e) { 27 | console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.'); 28 | console.error('To do that, run `npm install sails`'); 29 | console.error(''); 30 | console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.'); 31 | console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,'); 32 | console.error('but if it doesn\'t, the app will run with the global sails instead!'); 33 | return; 34 | } 35 | 36 | // Start server 37 | sails.lift(); 38 | -------------------------------------------------------------------------------- /assets/css/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgress454/angular-on-sails/38e11acdb46d4a6ac8bde355c102e78449fee154/assets/css/.gitkeep -------------------------------------------------------------------------------- /assets/css/app.css: -------------------------------------------------------------------------------- 1 | /* app css stylesheet */ 2 | 3 | .menu { 4 | list-style: none; 5 | border-bottom: 0.1em solid black; 6 | margin-bottom: 2em; 7 | padding: 0 0 0.5em; 8 | } 9 | 10 | .menu:before { 11 | content: "["; 12 | } 13 | 14 | .menu:after { 15 | content: "]"; 16 | } 17 | 18 | .menu > li { 19 | display: inline; 20 | } 21 | 22 | .menu > li:before { 23 | content: "|"; 24 | padding-right: 0.3em; 25 | } 26 | 27 | .menu > li:nth-child(1):before { 28 | content: ""; 29 | padding: 0; 30 | } 31 | -------------------------------------------------------------------------------- /assets/img/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgress454/angular-on-sails/38e11acdb46d4a6ac8bde355c102e78449fee154/assets/img/.gitkeep -------------------------------------------------------------------------------- /assets/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |This is the partial for view 2.
2 |3 | Showing of 'interpolate' filter: 4 | {{ 'Current version is v%VERSION%.' | interpolate }} 5 |
6 | -------------------------------------------------------------------------------- /config/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Bootstrap 3 | * 4 | * An asynchronous bootstrap function that runs before your Sails app gets lifted. 5 | * This gives you an opportunity to set up your data model, run jobs, or perform some special logic. 6 | * 7 | * For more information on bootstrapping your app, check out: 8 | * http://sailsjs.org/#documentation 9 | */ 10 | 11 | module.exports.bootstrap = function (cb) { 12 | 13 | // It's very important to trigger this callack method when you are finished 14 | // with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap) 15 | cb(); 16 | }; -------------------------------------------------------------------------------- /config/cors.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Cross-Origin Resource Sharing (CORS) 3 | * 4 | * CORS is like a more modern version of JSONP-- it allows your server/API 5 | * to successfully respond to requests from client-side JavaScript code 6 | * running on some other domain (e.g. google.com) 7 | * Unlike JSONP, it works with POST, PUT, and DELETE requests 8 | * 9 | * For more information on CORS, check out: 10 | * http://en.wikipedia.org/wiki/Cross-origin_resource_sharing 11 | * 12 | * Note that any of these settings (besides 'allRoutes') can be changed on a per-route basis 13 | * by adding a "cors" object to the route configuration: 14 | * 15 | * '/get foo': { 16 | * controller: 'foo', 17 | * action: 'bar', 18 | * cors: { 19 | * origin: 'http://foobar.com,https://owlhoot.com' 20 | * } 21 | * } 22 | * 23 | */ 24 | 25 | module.exports.cors = { 26 | 27 | // Allow CORS on all routes by default? If not, you must enable CORS on a 28 | // per-route basis by either adding a "cors" configuration object 29 | // to the route config, or setting "cors:true" in the route config to 30 | // use the default settings below. 31 | allRoutes: false, 32 | 33 | // Which domains which are allowed CORS access? 34 | // This can be a comma-delimited list of hosts (beginning with http:// or https://) 35 | // or "*" to allow all domains CORS access. 36 | origin: '*', 37 | 38 | // Allow cookies to be shared for CORS requests? 39 | credentials: true, 40 | 41 | // Which methods should be allowed for CORS requests? This is only used 42 | // in response to preflight requests (see article linked above for more info) 43 | methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD', 44 | 45 | // Which headers should be allowed for CORS requests? This is only used 46 | // in response to preflight requests. 47 | headers: 'content-type' 48 | 49 | }; -------------------------------------------------------------------------------- /config/csrf.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Cross-Site Request Forgery Protection 3 | * 4 | * CSRF tokens are like a tracking chip. While a session tells the server that a user 5 | * "is who they say they are", a csrf token tells the server "you are where you say you are". 6 | * 7 | * When enabled, all non-GET requests to the Sails server must be accompanied by 8 | * a special token, identified as the '_csrf' parameter. 9 | * 10 | * This option protects your Sails app against cross-site request forgery (or CSRF) attacks. 11 | * A would-be attacker needs not only a user's session cookie, but also this timestamped, 12 | * secret CSRF token, which is refreshed/granted when the user visits a URL on your app's domain. 13 | * 14 | * This allows us to have certainty that our users' requests haven't been hijacked, 15 | * and that the requests they're making are intentional and legitimate. 16 | * 17 | * This token has a short-lived expiration timeline, and must be acquired by either: 18 | * 19 | * (a) For traditional view-driven web apps: 20 | * Fetching it from one of your views, where it may be accessed as 21 | * a local variable, e.g.: 22 | * 25 | * 26 | * or (b) For AJAX/Socket-heavy and/or single-page apps: 27 | * Sending a GET request to the `/csrfToken` route, where it will be returned 28 | * as JSON, e.g.: 29 | * { _csrf: 'ajg4JD(JGdajhLJALHDa' } 30 | * 31 | * 32 | * Enabling this option requires managing the token in your front-end app. 33 | * For traditional web apps, it's as easy as passing the data from a view into a form action. 34 | * In AJAX/Socket-heavy apps, just send a GET request to the /csrfToken route to get a valid token. 35 | * 36 | * For more information on CSRF, check out: 37 | * http://en.wikipedia.org/wiki/Cross-site_request_forgery 38 | */ 39 | 40 | module.exports.csrf = false; -------------------------------------------------------------------------------- /config/globals.js: -------------------------------------------------------------------------------- 1 | module.exports.globals = { 2 | _: true, 3 | async: true, 4 | sails: true, 5 | services: true, 6 | models: true 7 | }; 8 | -------------------------------------------------------------------------------- /config/i18n.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Internationalization / Localization Settings 3 | * 4 | * If your app will touch people from all over the world, i18n (or internationalization) 5 | * may be an important part of your international strategy. 6 | * 7 | * 8 | * For more information, check out: 9 | * http://sailsjs.org/#documentation 10 | */ 11 | 12 | module.exports.i18n = { 13 | 14 | // Which locales are supported? 15 | locales: ['en', 'es', 'fr', 'de'] 16 | 17 | }; 18 | -------------------------------------------------------------------------------- /config/locales/_README.md: -------------------------------------------------------------------------------- 1 | # Internationalization / Localization Settings 2 | 3 | ## Locale 4 | All locale files live under `config/locales`. Here is where you can add locale data as JSON key-value pairs. The name of the file should match the language that you are supporting, which allows for automatic language detection based on the user request. 5 | 6 | Here is an example locale stringfile for the Spanish language (`config/locales/es.json`): 7 | ```json 8 | { 9 | "Hello!": "Hola!", 10 | "Hello %s, how are you today?": "¿Hola %s, como estas?", 11 | } 12 | ``` 13 | ## Usage 14 | Locales can be accessed in controllers/policies through `res.i18n()`, or in views through the `__(key)` or `i18n(key)` functions. 15 | Remember that the keys are case sensitive and require exact key matches, e.g. 16 | 17 | ```ejs 18 |<%= i18n('That\'s right-- you can use either i18n() or __()') %>
21 | ``` 22 | 23 | ## Configuration 24 | Localization/internationalization config can be found in `config/i18n.js`, from where you can set your supported locales. -------------------------------------------------------------------------------- /config/locales/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "Welcome": "Wilkommen" 3 | } -------------------------------------------------------------------------------- /config/locales/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "Welcome": "Welcome" 3 | } 4 | -------------------------------------------------------------------------------- /config/locales/es.json: -------------------------------------------------------------------------------- 1 | { 2 | "Welcome": "Bienvenido" 3 | } 4 | -------------------------------------------------------------------------------- /config/locales/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "Welcome": "Bienvenue" 3 | } 4 | -------------------------------------------------------------------------------- /config/log.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Logger configuration 3 | * 4 | * Configure the log level for your app, as well as the transport 5 | * (Underneath the covers, Sails uses Winston for logging, which 6 | * allows for some pretty neat custom transports/adapters for log messages) 7 | * 8 | * For more information on the Sails logger, check out: 9 | * http://sailsjs.org/#documentation 10 | */ 11 | 12 | module.exports = { 13 | 14 | // Valid `level` configs: 15 | // i.e. the minimum log level to capture with sails.log.*() 16 | // 17 | // 'error' : Display calls to `.error()` 18 | // 'warn' : Display calls from `.error()` to `.warn()` 19 | // 'debug' : Display calls from `.error()`, `.warn()` to `.debug()` 20 | // 'info' : Display calls from `.error()`, `.warn()`, `.debug()` to `.info()` 21 | // 'verbose': Display calls from `.error()`, `.warn()`, `.debug()`, `.info()` to `.verbose()` 22 | // 23 | log: { 24 | level: 'info' 25 | } 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /config/models.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Models 3 | * (sails.config.models) 4 | * 5 | * Unless you override them, the following properties will be included 6 | * in each of your models. 7 | */ 8 | 9 | module.exports.models = { 10 | 11 | // Your app's default connection. 12 | // i.e. the name of one of your app's connections (see `config/connections.js`) 13 | // 14 | // (defaults to localDiskDb) 15 | connection: 'localDiskDb' 16 | }; 17 | -------------------------------------------------------------------------------- /config/routes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Routes 3 | * 4 | * Your routes map URLs to views and controllers. 5 | * 6 | * If Sails receives a URL that doesn't match any of the routes below, 7 | * it will check for matching files (images, scripts, stylesheets, etc.) 8 | * in your assets directory. e.g. `http://localhost:1337/images/foo.jpg` 9 | * might match an image file: `/assets/images/foo.jpg` 10 | * 11 | * Finally, if those don't match either, the default 404 handler is triggered. 12 | * See `config/404.js` to adjust your app's 404 logic. 13 | * 14 | * Note: Sails doesn't ACTUALLY serve stuff from `assets`-- the default Gruntfile in Sails copies 15 | * flat files from `assets` to `.tmp/public`. This allows you to do things like compile LESS or 16 | * CoffeeScript for the front-end. 17 | * 18 | * For more information on routes, check out: 19 | * http://sailsjs.org/#documentation 20 | */ 21 | 22 | module.exports.routes = { 23 | 24 | 25 | // Make the view located at `views/homepage.ejs` (or `views/homepage.jade`, etc. depending on your 26 | // default view engine) your home page. 27 | // 28 | // (Alternatively, remove this and add an `index.html` file in your `assets` directory) 29 | '/': { 30 | view: 'homepage' 31 | }, 32 | 33 | 34 | // Custom routes here... 35 | 36 | 37 | // If a request to a URL doesn't match any of the custom routes above, it is matched 38 | // against Sails route blueprints. See `config/blueprints.js` for configuration options 39 | // and examples. 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /config/session.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Session 3 | * 4 | * Sails session integration leans heavily on the great work already done by Express, but also unifies 5 | * Socket.io with the Connect session store. It uses Connect's cookie parser to normalize configuration 6 | * differences between Express and Socket.io and hooks into Sails' middleware interpreter to allow you 7 | * to access and auto-save to `req.session` with Socket.io the same way you would with Express. 8 | * 9 | * For more information on configuring the session, check out: 10 | * http://sailsjs.org/#documentation 11 | */ 12 | 13 | module.exports.session = { 14 | 15 | // Session secret is automatically generated when your new app is created 16 | // Replace at your own risk in production-- you will invalidate the cookies of your users, 17 | // forcing them to log in again. 18 | secret: '957f7f7f30028d5029c7f0c7f087722c', 19 | 20 | 21 | // Set the session cookie expire time 22 | // The maxAge is set by milliseconds, the example below is for 24 hours 23 | // 24 | // cookie: { 25 | // maxAge: 24 * 60 * 60 * 1000 26 | // } 27 | 28 | 29 | // In production, uncomment the following lines to set up a shared redis session store 30 | // that can be shared across multiple Sails.js servers 31 | // adapter: 'redis', 32 | // 33 | // The following values are optional, if no options are set a redis instance running 34 | // on localhost is expected. 35 | // Read more about options at: https://github.com/visionmedia/connect-redis 36 | // 37 | // host: 'localhost', 38 | // port: 6379, 39 | // ttl: