Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit 74746d8

Browse files
committed
initial commit
0 parents  commit 74746d8

File tree

126 files changed

+10461
-0
lines changed

Some content is hidden

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

126 files changed

+10461
-0
lines changed

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "public/lib"
3+
}

.csslintrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"adjoining-classes": false,
3+
"box-model": false,
4+
"box-sizing": false,
5+
"floats": false,
6+
"font-sizes": false,
7+
"important": false,
8+
"known-properties": false,
9+
"overqualified-elements": false,
10+
"qualified-headings": false,
11+
"regex-selectors": false,
12+
"unique-headings": false,
13+
"universal-selector": false,
14+
"unqualified-attributes": false
15+
}

.editorconfig

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# Howto with your editor:
4+
# Sublime: https://github.com/sindresorhus/editorconfig-sublime
5+
6+
# top-most EditorConfig file
7+
root = true
8+
9+
# Unix-style newlines with a newline ending every file
10+
[**]
11+
end_of_line = lf
12+
insert_final_newline = true
13+
14+
# Standard at: https://github.com/felixge/node-style-guide
15+
[**.js, **.json]
16+
trim_trailing_whitespace = true
17+
indent_style = tab
18+
quote_type = single
19+
curly_bracket_next_line = false
20+
spaces_around_operators = true
21+
space_after_control_statements = true
22+
space_after_anonymous_functions = false
23+
spaces_in_brackets = false
24+
25+
# No Standard. Please document a standard if different from .js
26+
[**.yml, **.html, **.css]
27+
trim_trailing_whitespace = true
28+
indent_style = tab
29+
30+
# No standard. Please document a standard if different from .js
31+
[**.md]
32+
indent_style = tab
33+
34+
# Standard at:
35+
[Makefile]
36+
indent_style = tab

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.nodemonignore
3+
.sass-cache/
4+
npm-debug.log
5+
node_modules/
6+
public/lib
7+
app/tests/coverage/
8+
.bower-*/
9+
.idea/
10+
app/data

.jshintrc

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
3+
"browser": true, // Standard browser globals e.g. `window`, `document`.
4+
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
5+
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
6+
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
7+
"curly": false, // Require {} for every new block or scope.
8+
"eqeqeq": true, // Require triple equals i.e. `===`.
9+
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
10+
"latedef": true, // Prohibit variable use before definition.
11+
"newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
12+
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
13+
"quotmark": "single", // Define quotes to string values.
14+
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
15+
"undef": true, // Require all non-global variables be declared before they are used.
16+
"unused": false, // Warn unused variables.
17+
"strict": true, // Require `use strict` pragma in every file.
18+
"trailing": true, // Prohibit trailing whitespaces.
19+
"smarttabs": false, // Suppresses warnings about mixed tabs and spaces
20+
"globals": { // Globals variables.
21+
"jasmine": true,
22+
"angular": true,
23+
"ApplicationConfiguration": true
24+
},
25+
"predef": [ // Extra globals.
26+
"define",
27+
"require",
28+
"exports",
29+
"module",
30+
"describe",
31+
"before",
32+
"beforeEach",
33+
"after",
34+
"afterEach",
35+
"it",
36+
"inject",
37+
"expect"
38+
],
39+
"indent": 4, // Specify indentation spacing
40+
"devel": true, // Allow development statements e.g. `console.log();`.
41+
"noempty": true // Prohibit use of empty blocks.
42+
}

.slugignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/app/tests

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"
4+
env:
5+
- NODE_ENV=travis
6+
services:
7+
- mongodb

Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM dockerfile/nodejs
2+
3+
MAINTAINER Matthias Luebken, [email protected]
4+
5+
WORKDIR /home/mean
6+
7+
# Install Mean.JS Prerequisites
8+
RUN npm install -g grunt-cli
9+
RUN npm install -g bower
10+
11+
# Install Mean.JS packages
12+
ADD package.json /home/mean/package.json
13+
RUN npm install
14+
15+
# Manually trigger bower. Why doesnt this work via npm install?
16+
ADD .bowerrc /home/mean/.bowerrc
17+
ADD bower.json /home/mean/bower.json
18+
RUN bower install --config.interactive=false --allow-root
19+
20+
# Make everything available for start
21+
ADD . /home/mean
22+
23+
# currently only works for development
24+
ENV NODE_ENV development
25+
26+
# Port 3000 for server
27+
# Port 35729 for livereload
28+
EXPOSE 3000 35729
29+
CMD ["grunt"]

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## License
2+
(The MIT License)
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
'Software'), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: ./node_modules/.bin/forever -m 5 server.js

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Initial version of tenant resolutions webapp through Blue Ridge Labs. Repo/product name TBD
2+
3+
## License
4+
(The MIT License)
5+
6+
Permission is hereby granted, free of charge, to any person obtaining
7+
a copy of this software and associated documentation files (the
8+
'Software'), to deal in the Software without restriction, including
9+
without limitation the rights to use, copy, modify, merge, publish,
10+
distribute, sublicense, and/or sell copies of the Software, and to
11+
permit persons to whom the Software is furnished to do so, subject to
12+
the following conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var mongoose = require('mongoose'),
7+
errorHandler = require('./errors.server.controller'),
8+
Article = mongoose.model('Article'),
9+
_ = require('lodash');
10+
11+
/**
12+
* Create a article
13+
*/
14+
exports.create = function(req, res) {
15+
16+
var article = new Article(req.body);
17+
article.user = req.user;
18+
19+
article.save(function(err) {
20+
if (err) {
21+
return res.status(400).send({
22+
message: errorHandler.getErrorMessage(err)
23+
});
24+
} else {
25+
res.json(article);
26+
}
27+
});
28+
};
29+
30+
/**
31+
* Show the current article
32+
*/
33+
exports.read = function(req, res) {
34+
res.json(req.article);
35+
};
36+
37+
/**
38+
* Update a article
39+
*/
40+
exports.update = function(req, res) {
41+
var article = req.article;
42+
43+
article = _.extend(article, req.body);
44+
45+
article.save(function(err) {
46+
if (err) {
47+
return res.status(400).send({
48+
message: errorHandler.getErrorMessage(err)
49+
});
50+
} else {
51+
res.json(article);
52+
}
53+
});
54+
};
55+
56+
/**
57+
* Delete an article
58+
*/
59+
exports.delete = function(req, res) {
60+
var article = req.article;
61+
62+
article.remove(function(err) {
63+
if (err) {
64+
return res.status(400).send({
65+
message: errorHandler.getErrorMessage(err)
66+
});
67+
} else {
68+
res.json(article);
69+
}
70+
});
71+
};
72+
73+
/**
74+
* List of Articles
75+
*/
76+
exports.list = function(req, res) {
77+
Article.find().sort('-created').populate('user', 'displayName').exec(function(err, articles) {
78+
if (err) {
79+
return res.status(400).send({
80+
message: errorHandler.getErrorMessage(err)
81+
});
82+
} else {
83+
res.json(articles);
84+
}
85+
});
86+
};
87+
88+
/**
89+
* Article middleware
90+
*/
91+
exports.articleByID = function(req, res, next, id) {
92+
Article.findById(id).populate('user', 'displayName').exec(function(err, article) {
93+
if (err) return next(err);
94+
if (!article) return next(new Error('Failed to load article ' + id));
95+
req.article = article;
96+
next();
97+
});
98+
};
99+
100+
/**
101+
* Article authorization middleware
102+
*/
103+
exports.hasAuthorization = function(req, res, next) {
104+
if (req.article.user.id !== req.user.id) {
105+
return res.status(403).send({
106+
message: 'User is not authorized'
107+
});
108+
}
109+
next();
110+
};
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
exports.index = function(req, res) {
7+
res.render('index', {
8+
user: req.user || null,
9+
request: req
10+
});
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
3+
/**
4+
* Get unique error field name
5+
*/
6+
var getUniqueErrorMessage = function(err) {
7+
var output;
8+
9+
try {
10+
var fieldName = err.err.substring(err.err.lastIndexOf('.$') + 2, err.err.lastIndexOf('_1'));
11+
output = fieldName.charAt(0).toUpperCase() + fieldName.slice(1) + ' already exists';
12+
13+
} catch (ex) {
14+
output = 'Unique field already exists';
15+
}
16+
17+
return output;
18+
};
19+
20+
/**
21+
* Get the error message from error object
22+
*/
23+
exports.getErrorMessage = function(err) {
24+
var message = '';
25+
26+
console.log('[ERROR]', err);
27+
28+
if (err.code) {
29+
switch (err.code) {
30+
case 11000:
31+
case 11001:
32+
message = getUniqueErrorMessage(err);
33+
break;
34+
default:
35+
message = 'Something went wrong';
36+
}
37+
} else {
38+
for (var errName in err.errors) {
39+
if (err.errors[errName].message) message = err.errors[errName].message;
40+
}
41+
}
42+
43+
return message;
44+
};

0 commit comments

Comments
 (0)