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

Commit 8bc44f5

Browse files
author
Michael Mrowetz
committed
update sails skeleton to sails 0.12.13 and swagger-sails-hook 0.7.0
1 parent facfaf3 commit 8bc44f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1953
-1033
lines changed

project-skeletons/sails/.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

project-skeletons/sails/.gitignore

Lines changed: 110 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,120 @@
1-
# IDE files
2-
.idea
1+
################################################
2+
############### .gitignore ##################
3+
################################################
4+
#
5+
# This file is only relevant if you are using git.
6+
#
7+
# Files which match the splat patterns below will
8+
# be ignored by git. This keeps random crap and
9+
# sensitive credentials from being uploaded to
10+
# your repository. It allows you to configure your
11+
# app for your machine without accidentally
12+
# committing settings which will smash the local
13+
# settings of other developers on your team.
14+
#
15+
# Some reasonable defaults are included below,
16+
# but, of course, you should modify/extend/prune
17+
# to fit your needs!
18+
################################################
319

4-
# Logs
5-
logs
6-
*.log
720

8-
# Runtime data
9-
pids
10-
*.pid
11-
*.seed
1221

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

16-
# Coverage directory used by tools like istanbul
17-
coverage
23+
################################################
24+
# Local Configuration
25+
#
26+
# Explicitly ignore files which contain:
27+
#
28+
# 1. Sensitive information you'd rather not push to
29+
# your git repository.
30+
# e.g., your personal API keys or passwords.
31+
#
32+
# 2. Environment-specific configuration
33+
# Basically, anything that would be annoying
34+
# to have to change every time you do a
35+
# `git pull`
36+
# e.g., your local development database, or
37+
# the S3 bucket you're using for file uploads
38+
# development.
39+
#
40+
################################################
41+
42+
config/local.js
43+
1844

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

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

25-
# Dependency directory
26-
# Commenting this out is preferred by some people, see
27-
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
47+
48+
################################################
49+
# Dependencies
50+
#
51+
# When releasing a production app, you may
52+
# consider including your node_modules and
53+
# bower_components directory in your git repo,
54+
# but during development, its best to exclude it,
55+
# since different developers may be working on
56+
# different kernels, where dependencies would
57+
# need to be recompiled anyway.
58+
#
59+
# More on that here about node_modules dir:
60+
# http://www.futurealoof.com/posts/nodemodules-in-git.html
61+
# (credit Mikeal Rogers, @mikeal)
62+
#
63+
# About bower_components dir, you can see this:
64+
# http://addyosmani.com/blog/checking-in-front-end-dependencies/
65+
# (credit Addy Osmani, @addyosmani)
66+
#
67+
################################################
68+
2869
node_modules
70+
bower_components
71+
72+
73+
74+
75+
################################################
76+
# Sails.js / Waterline / Grunt
77+
#
78+
# Files generated by Sails and Grunt, or related
79+
# tasks and adapters.
80+
################################################
81+
.tmp
82+
dump.rdb
83+
2984

30-
# Users Environment Variables
31-
.lock-wscript
3285

33-
# Runtime configuration for swagger app
34-
config/runtime.yaml
86+
87+
88+
################################################
89+
# Node.js / NPM
90+
#
91+
# Common files generated by Node, NPM, and the
92+
# related ecosystem.
93+
################################################
94+
lib-cov
95+
*.seed
96+
*.log
97+
*.out
98+
*.pid
99+
npm-debug.log
100+
101+
102+
103+
104+
105+
################################################
106+
# Miscellaneous
107+
#
108+
# Common files generated by text editors,
109+
# operating systems, file systems, etc.
110+
################################################
111+
112+
*~
113+
*#
114+
.DS_STORE
115+
.netbeans
116+
nbproject
117+
.idea
118+
.node_history
119+
.vscode
120+
.DS_STORE

project-skeletons/sails/.sailsrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"generators": {
3+
"modules": {}
4+
}
5+
}

project-skeletons/sails/Gruntfile.js

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,67 +15,68 @@
1515
module.exports = function(grunt) {
1616

1717

18-
// Load the include-all library in order to require all of our grunt
19-
// configurations and task registrations dynamically.
20-
var includeAll;
21-
try {
22-
includeAll = require('include-all');
23-
} catch (e0) {
24-
try {
25-
includeAll = require('sails/node_modules/include-all');
26-
}
27-
catch(e1) {
28-
console.error('Could not find `include-all` module.');
29-
console.error('Skipping grunt tasks...');
30-
console.error('To fix this, please run:');
31-
console.error('npm install include-all --save`');
32-
console.error();
18+
// Load the include-all library in order to require all of our grunt
19+
// configurations and task registrations dynamically.
20+
var includeAll;
21+
try {
22+
includeAll = require('include-all');
23+
} catch (e0) {
24+
try {
25+
includeAll = require('sails/node_modules/include-all');
26+
} catch (e1) {
27+
console.error('Could not find `include-all` module.');
28+
console.error('Skipping grunt tasks...');
29+
console.error('To fix this, please run:');
30+
console.error('npm install include-all --save`');
31+
console.error();
3332

34-
grunt.registerTask('default', []);
35-
return;
36-
}
37-
}
33+
grunt.registerTask('default', []);
34+
return;
35+
}
36+
}
3837

3938

40-
/**
41-
* Loads Grunt configuration modules from the specified
42-
* relative path. These modules should export a function
43-
* that, when run, should either load/configure or register
44-
* a Grunt task.
45-
*/
46-
function loadTasks(relPath) {
47-
return includeAll({
48-
dirname: require('path').resolve(__dirname, relPath),
49-
filter: /(.+)\.js$/
50-
}) || {};
51-
}
39+
/**
40+
* Loads Grunt configuration modules from the specified
41+
* relative path. These modules should export a function
42+
* that, when run, should either load/configure or register
43+
* a Grunt task.
44+
*/
45+
function loadTasks(relPath) {
46+
return includeAll({
47+
dirname: require('path').resolve(__dirname, relPath),
48+
filter: /(.+)\.js$/,
49+
excludeDirs: /^\.(git|svn)$/
50+
}) || {};
51+
}
5252

53-
/**
54-
* Invokes the function from a Grunt configuration module with
55-
* a single argument - the `grunt` object.
56-
*/
57-
function invokeConfigFn(tasks) {
58-
for (var taskName in tasks) {
59-
if (tasks.hasOwnProperty(taskName)) {
60-
tasks[taskName](grunt);
61-
}
62-
}
63-
}
53+
/**
54+
* Invokes the function from a Grunt configuration module with
55+
* a single argument - the `grunt` object.
56+
*/
57+
function invokeConfigFn(tasks) {
58+
for (var taskName in tasks) {
59+
if (tasks.hasOwnProperty(taskName)) {
60+
tasks[taskName](grunt);
61+
}
62+
}
63+
}
6464

6565

6666

67+
// Load task functions
68+
var taskConfigurations = loadTasks('./tasks/config'),
69+
registerDefinitions = loadTasks('./tasks/register');
6770

68-
// Load task functions
69-
var taskConfigurations = loadTasks('./tasks/config'),
70-
registerDefinitions = loadTasks('./tasks/register');
71+
// (ensure that a default task exists)
72+
if (!registerDefinitions.default) {
73+
registerDefinitions.default = function(grunt) {
74+
grunt.registerTask('default', []);
75+
};
76+
}
7177

72-
// (ensure that a default task exists)
73-
if (!registerDefinitions.default) {
74-
registerDefinitions.default = function (grunt) { grunt.registerTask('default', []); };
75-
}
76-
77-
// Run task functions to configure Grunt.
78-
invokeConfigFn(taskConfigurations);
79-
invokeConfigFn(registerDefinitions);
78+
// Run task functions to configure Grunt.
79+
invokeConfigFn(taskConfigurations);
80+
invokeConfigFn(registerDefinitions);
8081

8182
};

project-skeletons/sails/api/policies/sessionAuth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @module :: Policy
55
* @description :: Simple policy to allow any authenticated user
66
* Assumes that your login action in one of your controllers sets `req.session.authenticated = true;`
7-
* @docs :: http://sailsjs.org/#!documentation/policies
7+
* @docs :: http://sailsjs.org/#!/documentation/concepts/Policies
88
*
99
*/
1010
module.exports = function(req, res, next) {

project-skeletons/sails/api/responses/badRequest.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,41 @@ module.exports = function badRequest(data, options) {
3434
// Only include errors in response if application environment
3535
// is not set to 'production'. In production, we shouldn't
3636
// send back any identifying information about errors.
37-
if (sails.config.environment === 'production') {
37+
if (sails.config.environment === 'production' && sails.config.keepResponseErrors !== true) {
3838
data = undefined;
3939
}
4040

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

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

51+
// Attempt to prettify data for views, if it's a non-error object
52+
var viewData = data;
53+
if (!(viewData instanceof Error) && 'object' == typeof viewData) {
54+
try {
55+
viewData = require('util').inspect(data, {depth: null});
56+
}
57+
catch(e) {
58+
viewData = undefined;
59+
}
60+
}
61+
5062
// If a view was provided in options, serve it.
5163
// Otherwise try to guess an appropriate view, or if that doesn't
5264
// work, just send JSON.
5365
if (options.view) {
54-
return res.view(options.view, { data: data });
66+
return res.view(options.view, { data: viewData, title: 'Bad Request' });
5567
}
5668

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

0 commit comments

Comments
 (0)