Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
update sails skeleton to sails 0.12.13 and swagger-sails-hook 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mrowetz committed Apr 15, 2017
1 parent facfaf3 commit 8bc44f5
Show file tree
Hide file tree
Showing 59 changed files with 1,953 additions and 1,033 deletions.
10 changes: 10 additions & 0 deletions project-skeletons/sails/.editorconfig
@@ -0,0 +1,10 @@
# 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
134 changes: 110 additions & 24 deletions project-skeletons/sails/.gitignore
@@ -1,34 +1,120 @@
# IDE files
.idea
################################################
############### .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
# 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!
################################################

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
################################################
# 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


# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git

################################################
# 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, or related
# tasks and adapters.
################################################
.tmp
dump.rdb


# Users Environment Variables
.lock-wscript

# Runtime configuration for swagger app
config/runtime.yaml


################################################
# 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
.node_history
.vscode
.DS_STORE
5 changes: 5 additions & 0 deletions project-skeletons/sails/.sailsrc
@@ -0,0 +1,5 @@
{
"generators": {
"modules": {}
}
}
107 changes: 54 additions & 53 deletions project-skeletons/sails/Gruntfile.js
Expand Up @@ -15,67 +15,68 @@
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();
// 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;
}
}
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$/
}) || {};
}
/**
* 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$/,
excludeDirs: /^\.(git|svn)$/
}) || {};
}

/**
* 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);
}
}
}
/**
* 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');

// 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', []);
};
}

// (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);
// Run task functions to configure Grunt.
invokeConfigFn(taskConfigurations);
invokeConfigFn(registerDefinitions);

};
2 changes: 1 addition & 1 deletion project-skeletons/sails/api/policies/sessionAuth.js
Expand Up @@ -4,7 +4,7 @@
* @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
* @docs :: http://sailsjs.org/#!/documentation/concepts/Policies
*
*/
module.exports = function(req, res, next) {
Expand Down
20 changes: 16 additions & 4 deletions project-skeletons/sails/api/responses/badRequest.js
Expand Up @@ -34,29 +34,41 @@ module.exports = function badRequest(data, options) {
// Only include errors in response if application environment
// is not set to 'production'. In production, we shouldn't
// send back any identifying information about errors.
if (sails.config.environment === 'production') {
if (sails.config.environment === 'production' && sails.config.keepResponseErrors !== true) {
data = undefined;
}

// If the user-agent wants JSON, always respond with JSON
if (req.wantsJSON) {
// If views are disabled, revert to json
if (req.wantsJSON || sails.config.hooks.views === false) {
return res.jsonx(data);
}

// If second argument is a string, we take that to mean it refers to a view.
// If it was omitted, use an empty object (`{}`)
options = (typeof options === 'string') ? { view: options } : options || {};

// Attempt to prettify data for views, if it's a non-error object
var viewData = data;
if (!(viewData instanceof Error) && 'object' == typeof viewData) {
try {
viewData = require('util').inspect(data, {depth: null});
}
catch(e) {
viewData = undefined;
}
}

// If a view was provided in options, serve it.
// Otherwise try to guess an appropriate view, or if that doesn't
// work, just send JSON.
if (options.view) {
return res.view(options.view, { data: data });
return res.view(options.view, { data: viewData, title: 'Bad Request' });
}

// If no second argument provided, try to serve the implied view,
// but fall back to sending JSON(P) if no view can be inferred.
else return res.guessView({ data: data }, function couldNotGuessView () {
else return res.guessView({ data: viewData, title: 'Bad Request' }, function couldNotGuessView () {
return res.jsonx(data);
});

Expand Down

0 comments on commit 8bc44f5

Please sign in to comment.