Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
dirrk committed Oct 15, 2015
0 parents commit 4f062da
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
quote_type = single

[Makefile]
indent_style = tab

[*.js]
space_after_control_statements = true
space_after_anonymous_functions = true
spaces_around_operators = true
spaces_in_brackets = hybrid

[package.json]
indent_size = 2
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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*

# 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
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
.idea
50 changes: 50 additions & 0 deletions .jscrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"disallowEmptyBlocks": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpaceBeforeBinaryOperators": [
","
],
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowYodaConditions": true,
"disallowKeywords": [ "with" ],
"disallowNewlineBeforeBlockStatements": true,
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireMultipleVarDecl": "onevar",
"requireBlocksOnNewline": 1,
"requireCommaBeforeLineBreak": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceAfterBinaryOperators": true,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"requireCurlyBraces": [
"do"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"typeof"
],
"safeContextKeyword": ["_this", "self"],
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"excludeFiles": ["node_modules/**"]
}
22 changes: 22 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"eqnull": true,
"nonew": true,
"curly": true,
"unused": "vars",
"noarg": true,
"indent": 4,
"forin": true,
"noempty": true,
"quotmark": "single",
"node": true,
"eqeqeq": true,
"strict": true,
"undef": true,
"bitwise": true,
"newcap": true,
"immed": true,
"nonbsp": true,
"freeze": true,
"globalstrict": true
}

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hampton Roads Resolutions
=================

23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

// Setup hapi
var setup = require('./lib/setup');

setup(function (err) {
if (err) {
exit(err);
} else {
console.log('Setup server completed');
}
process.on('uncaughtException', exit);
process.on('uncaughtRejection', exit);
process.on('error', exit);
});


function exit(err) {
if (err) {
console.error(err);
}
process.exit(err ? 1 : 0);
}
8 changes: 8 additions & 0 deletions lib/api/report/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

exports.createReport = function (request, reply) {
reply({
status: 200,
tracking: '000000-00000-000000000'
});
};
9 changes: 9 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var constants = {
server: {
port: 3000
}
};

module.exports = Object.freeze(constants);
9 changes: 9 additions & 0 deletions lib/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var report = require('./api/report');

module.exports = [
{ method: 'GET', path: '/', handler: { file: function () { return 'public/index.html'; }}},
{ method: 'GET', path: '/javascript/{file?}', handler: { directory: { path: 'public/javascript/'}}},
{ method: 'POST', path: '/api/report', handler: report.createReport }
];
26 changes: 26 additions & 0 deletions lib/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

var Hapi = require('hapi'),
config = require('./config');

module.exports = function (next) {
var server = new Hapi.Server();

server.connection(config.server);
server.start(function (err) {
if (err) {
return next(err);
}
console.log('Server listening on ', server.info.uri);
setupRoutes(server, next);
});
};

function setupRoutes(server, next) {
var routes = require('./routes');

routes.forEach(function (route) {
server.route(route);
});
next();
}
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "2015-hr-resolution",
"version": "1.0.0",
"description": "2015 DE Hampton Roads Resolutions app",
"main": "index.js",
"scripts": {
"test": "npm test"
},
"dependencies": {
"hapi": "8.x.x"
},
"author": "Homes.com",
"license": "MIT"
}
8 changes: 8 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<script type="text/javascript" src="/javascript/test.js"></script>
</head>
<body>
<h2> Hello World </h2>
</body>
</html>
2 changes: 2 additions & 0 deletions public/javascript/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var a = 'Hello world';
console.log(a);

0 comments on commit 4f062da

Please sign in to comment.