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

Commit 447c5b3

Browse files
author
Chandra Pratap
authored
initial commit (#279)
1 parent 4f4441f commit 447c5b3

Some content is hidden

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

90 files changed

+15146
-0
lines changed
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
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
44+
45+
46+
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+
69+
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+
84+
85+
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
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+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:8
2+
LABEL maintainer="Azure App Service Container Images <[email protected]>"
3+
4+
# Create app directory
5+
WORKDIR /app
6+
7+
# Bundle app source
8+
COPY . .
9+
RUN npm install
10+
11+
EXPOSE 3000 80
12+
CMD [ "npm", "start" ]
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
} 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();
32+
33+
grunt.registerTask('default', []);
34+
return;
35+
}
36+
}
37+
38+
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+
}
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+
// Load task functions
68+
var taskConfigurations = loadTasks('./tasks/config'),
69+
registerDefinitions = loadTasks('./tasks/register');
70+
71+
// (ensure that a default task exists)
72+
if (!registerDefinitions.default) {
73+
registerDefinitions.default = function(grunt) {
74+
grunt.registerTask('default', []);
75+
};
76+
}
77+
78+
// Run task functions to configure Grunt.
79+
invokeConfigFn(taskConfigurations);
80+
invokeConfigFn(registerDefinitions);
81+
82+
};

github/node/sail.js/containerWithTests/Application/api/controllers/.gitkeep

Whitespace-only changes.

github/node/sail.js/containerWithTests/Application/api/models/.gitkeep

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
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+
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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' && sails.config.keepResponseErrors !== true) {
38+
data = undefined;
39+
}
40+
41+
// If the user-agent wants JSON, always respond with JSON
42+
// If views are disabled, revert to json
43+
if (req.wantsJSON || sails.config.hooks.views === false) {
44+
return res.jsonx(data);
45+
}
46+
47+
// If second argument is a string, we take that to mean it refers to a view.
48+
// If it was omitted, use an empty object (`{}`)
49+
options = (typeof options === 'string') ? { view: options } : options || {};
50+
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+
62+
// If a view was provided in options, serve it.
63+
// Otherwise try to guess an appropriate view, or if that doesn't
64+
// work, just send JSON.
65+
if (options.view) {
66+
return res.view(options.view, { data: viewData, title: 'Bad Request' });
67+
}
68+
69+
// If no second argument provided, try to serve the implied view,
70+
// but fall back to sending JSON(P) if no view can be inferred.
71+
else return res.guessView({ data: viewData, title: 'Bad Request' }, function couldNotGuessView () {
72+
return res.jsonx(data);
73+
});
74+
75+
};
76+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* 201 (CREATED) Response
3+
*
4+
* Usage:
5+
* return res.created();
6+
* return res.created(data);
7+
* return res.created(data, 'auth/login');
8+
*
9+
* @param {Object} data
10+
* @param {String|Object} options
11+
* - pass string to render specified view
12+
*/
13+
14+
module.exports = function created (data, options) {
15+
16+
// Get access to `req`, `res`, & `sails`
17+
var req = this.req;
18+
var res = this.res;
19+
var sails = req._sails;
20+
21+
sails.log.silly('res.created() :: Sending 201 ("CREATED") response');
22+
23+
// Set status code
24+
res.status(201);
25+
26+
// If appropriate, serve data as JSON(P)
27+
// If views are disabled, revert to json
28+
if (req.wantsJSON || sails.config.hooks.views === false) {
29+
return res.jsonx(data);
30+
}
31+
32+
// If second argument is a string, we take that to mean it refers to a view.
33+
// If it was omitted, use an empty object (`{}`)
34+
options = (typeof options === 'string') ? { view: options } : options || {};
35+
36+
// Attempt to prettify data for views, if it's a non-error object
37+
var viewData = data;
38+
if (!(viewData instanceof Error) && 'object' == typeof viewData) {
39+
try {
40+
viewData = require('util').inspect(data, {depth: null});
41+
}
42+
catch(e) {
43+
viewData = undefined;
44+
}
45+
}
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: viewData, title: 'Created' });
52+
}
53+
54+
// If no second argument provided, try to serve the implied view,
55+
// but fall back to sending JSON(P) if no view can be inferred.
56+
else return res.guessView({ data: viewData, title: 'Created' }, function couldNotGuessView () {
57+
return res.jsonx(data);
58+
});
59+
60+
};

0 commit comments

Comments
 (0)