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

[Assignment 1] Basic server #7

Merged
merged 7 commits into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from 6 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.*
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/index.js');

Choose a reason for hiding this comment

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

No reason to export anything here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just require('./lib/index.js'); then? Or even require('./lib') although i'm not familiar with what it will do then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok found it in the docs will patch

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 internals = {
pkg: require('../package.json')
};

var server = new Hapi.Server();

server.connection({ port: process.env.PORT || 8000 });

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

return reply({ version: internals.pkg.version });
},
description: 'Returns the version of the server'

Choose a reason for hiding this comment

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

description better placed before handler. Easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lgtm will patch, thanks for all the feedback!

}
});

server.start(function (err) {

Hoek.assert(!err, err);

// once we have something like good-console we can use server.log here
console.log('Server started at: ' + server.info.uri);
});
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "hueniversity",
"version": "0.0.1",
"description": "Community learning experiment",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"repository": {
"type": "git",
"url": "https://github.com/hueniverse/hueniversity.git"
},
"keywords": [
"hapi",
"hapijs",
"hapi.js"
],
"author": "Hueniversity students",
"license": "BSD",
"bugs": {
"url": "https://github.com/hueniverse/hueniversity/issues"
},
"homepage": "https://github.com/hueniverse/hueniversity",
"dependencies": {
"hapi": "8.4.x",
"hoek": "2.11.x"
}
}