-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
373 changed files
with
6,297 additions
and
55,362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
################################################ | ||
############### .gitignore ################## | ||
################################################ | ||
# | ||
# This file is only relevant if you are using git. | ||
# | ||
# Files which match the splat patterns below will | ||
# be ignored by git. This keeps random crap and | ||
# and sensitive credentials from being uploaded to | ||
# your repository. 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. Environment-specific configuration | ||
# Basically, anything that would be annoying | ||
# to have to change every time you do a | ||
# `git pull` | ||
# e.g., your local development database, or | ||
# the S3 bucket you're using for file uploads | ||
# development. | ||
# | ||
################################################ | ||
|
||
config/local.js | ||
|
||
|
||
|
||
|
||
|
||
################################################ | ||
# Dependencies | ||
# | ||
# When releasing a production app, you may | ||
# consider including your node_modules and | ||
# bower_components directory in your git repo, | ||
# but during development, its best to exclude it, | ||
# since different developers may be working on | ||
# different kernels, where dependencies would | ||
# need to be recompiled anyway. | ||
# | ||
# More on that here about node_modules dir: | ||
# http://www.futurealoof.com/posts/nodemodules-in-git.html | ||
# (credit Mikeal Rogers, @mikeal) | ||
# | ||
# About bower_components dir, you can see this: | ||
# http://addyosmani.com/blog/checking-in-front-end-dependencies/ | ||
# (credit Addy Osmani, @addyosmani) | ||
# | ||
################################################ | ||
|
||
node_modules | ||
bower_components | ||
|
||
|
||
|
||
|
||
|
||
################################################ | ||
# Sails.js / Waterline / Grunt | ||
# | ||
# Files generated by Sails and Grunt. | ||
################################################ | ||
.tmp | ||
|
||
|
||
|
||
|
||
|
||
################################################ | ||
# Node.js / NPM | ||
# | ||
# Common files generated by Node, NPM, and the | ||
# related ecosystem. | ||
################################################ | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.out | ||
*.pid | ||
npm-debug.log | ||
|
||
|
||
|
||
|
||
|
||
################################################ | ||
# Miscellaneous | ||
# | ||
# Common files generated by text editors, | ||
# operating systems, file systems, etc. | ||
################################################ | ||
|
||
*~ | ||
*# | ||
.DS_STORE | ||
.netbeans | ||
nbproject | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"generators": { | ||
"modules": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Gruntfile | ||
* | ||
* This Node script is executed when you run `grunt` or `sails lift`. | ||
* It's purpose is to load the Grunt tasks in your project's `tasks` | ||
* folder, and allow you to add and remove tasks as you see fit. | ||
* For more information on how this works, check out the `README.md` | ||
* file that was generated in your `tasks` folder. | ||
* | ||
* WARNING: | ||
* Unless you know what you're doing, you shouldn't change this file. | ||
* Check out the `tasks` directory instead. | ||
*/ | ||
|
||
module.exports = function(grunt) { | ||
|
||
|
||
// Load the include-all library in order to require all of our grunt | ||
// configurations and task registrations dynamically. | ||
var includeAll; | ||
try { | ||
includeAll = require('include-all'); | ||
} catch (e0) { | ||
try { | ||
includeAll = require('sails/node_modules/include-all'); | ||
} | ||
catch(e1) { | ||
console.error('Could not find `include-all` module.'); | ||
console.error('Skipping grunt tasks...'); | ||
console.error('To fix this, please run:'); | ||
console.error('npm install include-all --save`'); | ||
console.error(); | ||
|
||
grunt.registerTask('default', []); | ||
return; | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Loads Grunt configuration modules from the specified | ||
* relative path. These modules should export a function | ||
* that, when run, should either load/configure or register | ||
* a Grunt task. | ||
*/ | ||
function loadTasks(relPath) { | ||
return includeAll({ | ||
dirname: require('path').resolve(__dirname, relPath), | ||
filter: /(.+)\.js$/ | ||
}) || {}; | ||
} | ||
|
||
/** | ||
* Invokes the function from a Grunt configuration module with | ||
* a single argument - the `grunt` object. | ||
*/ | ||
function invokeConfigFn(tasks) { | ||
for (var taskName in tasks) { | ||
if (tasks.hasOwnProperty(taskName)) { | ||
tasks[taskName](grunt); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
// Load task functions | ||
var taskConfigurations = loadTasks('./tasks/config'), | ||
registerDefinitions = loadTasks('./tasks/register'); | ||
|
||
// (ensure that a default task exists) | ||
if (!registerDefinitions.default) { | ||
registerDefinitions.default = function (grunt) { grunt.registerTask('default', []); }; | ||
} | ||
|
||
// Run task functions to configure Grunt. | ||
invokeConfigFn(taskConfigurations); | ||
invokeConfigFn(registerDefinitions); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: node index.js | ||
web: node app.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# mazio | ||
|
||
a [Sails](http://sailsjs.org) application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* sessionAuth | ||
* | ||
* @module :: Policy | ||
* @description :: Simple policy to allow any authenticated user | ||
* Assumes that your login action in one of your controllers sets `req.session.authenticated = true;` | ||
* @docs :: http://sailsjs.org/#!documentation/policies | ||
* | ||
*/ | ||
module.exports = function(req, res, next) { | ||
|
||
// User is allowed, proceed to the next policy, | ||
// or if this is the last policy, the controller | ||
if (req.session.authenticated) { | ||
return next(); | ||
} | ||
|
||
// User is not allowed | ||
// (default res.forbidden() behavior can be overridden in `config/403.js`) | ||
return res.forbidden('You are not permitted to perform this action.'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* 400 (Bad Request) Handler | ||
* | ||
* Usage: | ||
* return res.badRequest( | ||
* 'Please choose a valid `password` (6-12 characters)', | ||
* '/trial/signup' | ||
* ); | ||
* | ||
* @param {Array|Object|String} validationErrors | ||
* optional errors | ||
* usually an array of validation errors from the ORM | ||
* | ||
* @param {String} redirectTo | ||
* optional URL | ||
* (absolute or relative, e.g. google.com/foo or /bar/baz) | ||
* of the page to redirect to. Usually only relevant for traditional HTTP requests, | ||
* since if this was triggered from an AJAX or socket request, JSON should be sent instead. | ||
*/ | ||
|
||
module.exports = function badRequest(validationErrors, redirectTo) { | ||
|
||
// Get access to `req`, `res`, `sails` | ||
var req = this.req; | ||
var res = this.res; | ||
var sails = req._sails; | ||
|
||
var statusCode = 400; | ||
|
||
var result = { | ||
status: statusCode | ||
}; | ||
|
||
// Optional validationErrors object | ||
if (validationErrors) { | ||
result.validationErrors = validationErrors; | ||
} | ||
|
||
// For requesters expecting JSON, everything works like you would expect-- a simple JSON response | ||
// indicating the 400: Bad Request status with relevant information will be returned. | ||
if (req.wantsJSON) { | ||
return res.json(result, result.status); | ||
} | ||
|
||
// For traditional (not-AJAX) web forms, this middleware follows best-practices | ||
// for when a user submits invalid form data: | ||
// i. First, a one-time-use flash variable is populated, probably a string message or an array | ||
// of semantic validation error objects. | ||
// ii. Then the user is redirected back to `redirectTo`, i.e. the URL where the bad request originated. | ||
// iii. There, the controller and/or view might use the flash `errors` to either display a message or highlight | ||
// the invalid HTML form fields. | ||
if (redirectTo) { | ||
|
||
// Set flash message called `errors` (one-time-use in session) | ||
req.flash('errors', validationErrors); | ||
|
||
// then redirect back to the `redirectTo` URL | ||
return res.redirect(redirectTo); | ||
} | ||
|
||
|
||
// Depending on your app's needs, you may choose to look at the Referer header here | ||
// and redirect back. Please do so at your own risk! | ||
// For security reasons, Sails does not provide this affordance by default. | ||
// It's safest to provide a 'redirectTo' URL and redirect there directly. | ||
|
||
// If `redirectTo` was not specified, just respond w/ JSON | ||
return res.json(result, result.status); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* 403 (Forbidden) Handler | ||
* | ||
* Usage: | ||
* return res.forbidden('Access denied.'); | ||
* | ||
* @param {String|Object|Array} message | ||
* optional message to inject into view locals or JSON response | ||
* | ||
*/ | ||
|
||
module.exports = function forbidden(message) { | ||
|
||
// Get access to `req`, `res`, `sails` | ||
var req = this.req; | ||
var res = this.res; | ||
var sails = req._sails; | ||
|
||
var viewFilePath = '403'; | ||
var statusCode = 403; | ||
|
||
var result = { | ||
status: statusCode | ||
}; | ||
|
||
// Optional message | ||
if (message) { | ||
result.message = message; | ||
} | ||
|
||
// If the user-agent wants a JSON response, send json | ||
if (req.wantsJSON) { | ||
return res.json(result, result.status); | ||
} | ||
|
||
// Set status code and view locals | ||
res.status(result.status); | ||
for (var key in result) { | ||
res.locals[key] = result[key]; | ||
} | ||
// And render view | ||
res.render(viewFilePath, result, function(err) { | ||
// If the view doesn't exist, or an error occured, send json | ||
if (err) { | ||
return res.json(result, result.status); | ||
} | ||
|
||
// Otherwise, serve the `views/403.*` page | ||
res.render(viewFilePath); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* 404 (Not Found) Handler | ||
* | ||
* Usage: | ||
* return res.notFound(); | ||
* | ||
* NOTE: | ||
* If no user-defined route, blueprint route, or static file matches | ||
* the requested URL, Sails will call `res.notFound()`. | ||
*/ | ||
|
||
module.exports = function notFound() { | ||
|
||
// Get access to `req`, `res`, `sails` | ||
var req = this.req; | ||
var res = this.res; | ||
var sails = req._sails; | ||
|
||
var viewFilePath = '404'; | ||
var statusCode = 404; | ||
var result = { | ||
status: statusCode | ||
}; | ||
|
||
// If the user-agent wants a JSON response, send json | ||
if (req.wantsJSON) { | ||
return res.json(result, result.status); | ||
} | ||
|
||
res.status(result.status); | ||
res.render(viewFilePath, function(err) { | ||
// If the view doesn't exist, or an error occured, send json | ||
if (err) { | ||
return res.json(result, result.status); | ||
} | ||
|
||
// Otherwise, serve the `views/404.*` page | ||
res.render(viewFilePath); | ||
}); | ||
}; |
Oops, something went wrong.