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

[Assigment 1] Create http server #40

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.idea
*.iml
npm-debug.log
dump.rdb
node_modules
results.tap
results.xml
config.json
.DS_Store
*/.DS_Store
*/*/.DS_Store
._*
*/._*
*/*/._*
coverage.*
30 changes: 30 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var Hapi = require('hapi');
var Hoek = require('hoek');

var package = require('../package.json');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package is basically a module so the name should start with a capital letter var Package = ...


var internals = {
staticVersion: {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staticVersion isn't a very helpful name. versionResponse, response, etc. are more descriptive.

version: package.version
}
};

var server = new Hapi.Server();
server.connection({ port:8000 });

server.route({
method: 'GET',
path: '/version',
config: {
handler: function (request, reply) {

return reply(internals.staticVersion);
}
}
});

server.start(function (err) {

Hoek.assert(!err, err);
console.log('Server started listening at: ' + server.info.uri);
});
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "hueniversity",
"version": "0.0.1",
"description": "Hueniversity",
"main": "lib/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/hueniverse/hueniversity.git"
},
"keywords": [
"node",
"hapi"
],
"author": "",
"license": "BSD",
"bugs": {
"url": "https://github.com/hueniverse/hueniversity/issues"
},
"homepage": "https://github.com/hueniverse/hueniversity"
}