Skip to content

Commit fd942de

Browse files
committed
Initial Commit
0 parents  commit fd942de

Some content is hidden

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

69 files changed

+4078
-0
lines changed

.editorconfig

+10
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

.gitignore

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
################################################
19+
20+
21+
22+
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+
config/env/production.js
44+
45+
46+
47+
48+
49+
################################################
50+
# Dependencies
51+
#
52+
# When releasing a production app, you may
53+
# consider including your node_modules and
54+
# bower_components directory in your git repo,
55+
# but during development, its best to exclude it,
56+
# since different developers may be working on
57+
# different kernels, where dependencies would
58+
# need to be recompiled anyway.
59+
#
60+
# More on that here about node_modules dir:
61+
# http://www.futurealoof.com/posts/nodemodules-in-git.html
62+
# (credit Mikeal Rogers, @mikeal)
63+
#
64+
# About bower_components dir, you can see this:
65+
# http://addyosmani.com/blog/checking-in-front-end-dependencies/
66+
# (credit Addy Osmani, @addyosmani)
67+
#
68+
################################################
69+
70+
node_modules
71+
bower_components
72+
73+
74+
75+
76+
################################################
77+
# Sails.js / Waterline / Grunt
78+
#
79+
# Files generated by Sails and Grunt, or related
80+
# tasks and adapters.
81+
################################################
82+
.tmp
83+
dump.rdb
84+
85+
86+
87+
88+
89+
################################################
90+
# Node.js / NPM
91+
#
92+
# Common files generated by Node, NPM, and the
93+
# related ecosystem.
94+
################################################
95+
lib-cov
96+
*.seed
97+
*.log
98+
*.out
99+
*.pid
100+
npm-debug.log
101+
102+
103+
104+
105+
106+
################################################
107+
# Miscellaneous
108+
#
109+
# Common files generated by text editors,
110+
# operating systems, file systems, etc.
111+
################################################
112+
113+
*~
114+
*#
115+
.DS_STORE
116+
.netbeans
117+
nbproject
118+
.idea
119+
.node_history

.sailsrc

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

Gruntfile.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Gruntfile
3+
*
4+
* This Node script is executed when you run `grunt` or `sails lift`.
5+
* It's purpose is to load the Grunt tasks in your project's `tasks`
6+
* folder, and allow you to add and remove tasks as you see fit.
7+
* For more information on how this works, check out the `README.md`
8+
* file that was generated in your `tasks` folder.
9+
*
10+
* WARNING:
11+
* Unless you know what you're doing, you shouldn't change this file.
12+
* Check out the `tasks` directory instead.
13+
*/
14+
15+
module.exports = function(grunt) {
16+
17+
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();
33+
34+
grunt.registerTask('default', []);
35+
return;
36+
}
37+
}
38+
39+
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+
}
52+
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+
}
64+
65+
66+
67+
68+
// Load task functions
69+
var taskConfigurations = loadTasks('./tasks/config'),
70+
registerDefinitions = loadTasks('./tasks/register');
71+
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);
80+
81+
};

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# sourcecheck_node
2+
3+
a [Sails](http://sailsjs.org) application

api/controllers/.gitkeep

Whitespace-only changes.

api/models/.gitkeep

Whitespace-only changes.

api/policies/sessionAuth.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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/concepts/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+
};

api/responses/badRequest.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* 400 (Bad Request) Handler
3+
*
4+
* Usage:
5+
* return res.badRequest();
6+
* return res.badRequest(data);
7+
* return res.badRequest(data, 'some/specific/badRequest/view');
8+
*
9+
* e.g.:
10+
* ```
11+
* return res.badRequest(
12+
* 'Please choose a valid `password` (6-12 characters)',
13+
* 'trial/signup'
14+
* );
15+
* ```
16+
*/
17+
18+
module.exports = function badRequest(data, options) {
19+
20+
// Get access to `req`, `res`, & `sails`
21+
var req = this.req;
22+
var res = this.res;
23+
var sails = req._sails;
24+
25+
// Set status code
26+
res.status(400);
27+
28+
// Log error to console
29+
if (data !== undefined) {
30+
sails.log.verbose('Sending 400 ("Bad Request") response: \n',data);
31+
}
32+
else sails.log.verbose('Sending 400 ("Bad Request") response');
33+
34+
// Only include errors in response if application environment
35+
// is not set to 'production'. In production, we shouldn't
36+
// send back any identifying information about errors.
37+
if (sails.config.environment === 'production') {
38+
data = undefined;
39+
}
40+
41+
// If the user-agent wants JSON, always respond with JSON
42+
if (req.wantsJSON) {
43+
return res.jsonx(data);
44+
}
45+
46+
// If second argument is a string, we take that to mean it refers to a view.
47+
// If it was omitted, use an empty object (`{}`)
48+
options = (typeof options === 'string') ? { view: options } : options || {};
49+
50+
// If a view was provided in options, serve it.
51+
// Otherwise try to guess an appropriate view, or if that doesn't
52+
// work, just send JSON.
53+
if (options.view) {
54+
return res.view(options.view, { data: data });
55+
}
56+
57+
// If no second argument provided, try to serve the implied view,
58+
// but fall back to sending JSON(P) if no view can be inferred.
59+
else return res.guessView({ data: data }, function couldNotGuessView () {
60+
return res.jsonx(data);
61+
});
62+
63+
};
64+

api/responses/forbidden.js

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* 403 (Forbidden) Handler
3+
*
4+
* Usage:
5+
* return res.forbidden();
6+
* return res.forbidden(err);
7+
* return res.forbidden(err, 'some/specific/forbidden/view');
8+
*
9+
* e.g.:
10+
* ```
11+
* return res.forbidden('Access denied.');
12+
* ```
13+
*/
14+
15+
module.exports = function forbidden (data, options) {
16+
17+
// Get access to `req`, `res`, & `sails`
18+
var req = this.req;
19+
var res = this.res;
20+
var sails = req._sails;
21+
22+
// Set status code
23+
res.status(403);
24+
25+
// Log error to console
26+
if (data !== undefined) {
27+
sails.log.verbose('Sending 403 ("Forbidden") response: \n',data);
28+
}
29+
else sails.log.verbose('Sending 403 ("Forbidden") response');
30+
31+
// Only include errors in response if application environment
32+
// is not set to 'production'. In production, we shouldn't
33+
// send back any identifying information about errors.
34+
if (sails.config.environment === 'production') {
35+
data = undefined;
36+
}
37+
38+
// If the user-agent wants JSON, always respond with JSON
39+
if (req.wantsJSON) {
40+
return res.jsonx(data);
41+
}
42+
43+
// If second argument is a string, we take that to mean it refers to a view.
44+
// If it was omitted, use an empty object (`{}`)
45+
options = (typeof options === 'string') ? { view: options } : options || {};
46+
47+
// If a view was provided in options, serve it.
48+
// Otherwise try to guess an appropriate view, or if that doesn't
49+
// work, just send JSON.
50+
if (options.view) {
51+
return res.view(options.view, { data: data });
52+
}
53+
54+
// If no second argument provided, try to serve the default view,
55+
// but fall back to sending JSON(P) if any errors occur.
56+
else return res.view('403', { data: data }, function (err, html) {
57+
58+
// If a view error occured, fall back to JSON(P).
59+
if (err) {
60+
//
61+
// Additionally:
62+
// • If the view was missing, ignore the error but provide a verbose log.
63+
if (err.code === 'E_VIEW_FAILED') {
64+
sails.log.verbose('res.forbidden() :: Could not locate view for error page (sending JSON instead). Details: ',err);
65+
}
66+
// Otherwise, if this was a more serious error, log to the console with the details.
67+
else {
68+
sails.log.warn('res.forbidden() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
69+
}
70+
return res.jsonx(data);
71+
}
72+
73+
return res.send(html);
74+
});
75+
76+
};
77+

0 commit comments

Comments
 (0)