From 4d71fc53345a0a58e7fac16f660dfaf34d8932e9 Mon Sep 17 00:00:00 2001 From: AdriVanHoudt Date: Thu, 12 Mar 2015 10:38:26 +0100 Subject: [PATCH 1/7] Basic server --- .gitignore | 11 +++++++++++ index.js | 31 +++++++++++++++++++++++++++++++ lib/index.js | 0 package.json | 28 ++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 lib/index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..409095d --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.idea +*.iml +npm-debug.log +node_modules +.DS_Store +*/.DS_Store +*/*/.DS_Store +._* +*/._* +*/*/._* +coverage.* \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..42443b8 --- /dev/null +++ b/index.js @@ -0,0 +1,31 @@ +var Hapi = require('hapi'); + +var internals = { + pkg: require('./package.json') +}; + +var server = new Hapi.Server(); + +server.connection({ port: process.env.PORT || 8000 }); + +server.route({ + method: 'GET', + path: '/version', + handler: function (request, reply) { + + return reply({ version: internals.pkg.version }); + }, + config: { + description: 'Returns the version of the server' + } +}); + +server.start(function (err) { + + if (err) { + throw err + } + + // once we have something like good-console we can use server.log here + console.log('Server started at: ' + server.info.uri); +}); diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json new file mode 100644 index 0000000..73ac0b2 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "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": "ISC", + "bugs": { + "url": "https://github.com/hueniverse/hueniversity/issues" + }, + "homepage": "https://github.com/hueniverse/hueniversity", + "dependencies": { + "hapi": "8.3.x" + } +} From adf6eba948f2545f560f5b5f6c2c776f5f84739c Mon Sep 17 00:00:00 2001 From: AdriVanHoudt Date: Thu, 12 Mar 2015 10:40:38 +0100 Subject: [PATCH 2/7] Add new line to end gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 409095d..b0c272c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ node_modules ._* */._* */*/._* -coverage.* \ No newline at end of file +coverage.* From a70b834cda14ea17700e24a60cc87918f4a791cc Mon Sep 17 00:00:00 2001 From: AdriVanHoudt Date: Thu, 12 Mar 2015 23:02:55 +0100 Subject: [PATCH 3/7] tabs to spaces --- index.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 42443b8..5d91f66 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ var Hapi = require('hapi'); var internals = { - pkg: require('./package.json') + pkg: require('./package.json') }; var server = new Hapi.Server(); @@ -9,23 +9,23 @@ var server = new Hapi.Server(); server.connection({ port: process.env.PORT || 8000 }); server.route({ - method: 'GET', - path: '/version', - handler: function (request, reply) { - - return reply({ version: internals.pkg.version }); - }, - config: { - description: 'Returns the version of the server' - } + method: 'GET', + path: '/version', + handler: function (request, reply) { + + return reply({ version: internals.pkg.version }); + }, + config: { + description: 'Returns the version of the server' + } }); server.start(function (err) { - if (err) { - throw err - } + if (err) { + throw err + } - // once we have something like good-console we can use server.log here - console.log('Server started at: ' + server.info.uri); + // once we have something like good-console we can use server.log here + console.log('Server started at: ' + server.info.uri); }); From f6586d8b1996773bad84fb4c2515d98002a5ad0e Mon Sep 17 00:00:00 2001 From: AdriVanHoudt Date: Sun, 15 Mar 2015 19:36:26 +0100 Subject: [PATCH 4/7] [DEP] Hapi 8.3.x to Hapi 8.4.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73ac0b2..9b27e00 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,6 @@ }, "homepage": "https://github.com/hueniverse/hueniversity", "dependencies": { - "hapi": "8.3.x" + "hapi": "8.4.x" } } From d77149414213f1f3ae74d9b0f329b0d8c6a1479b Mon Sep 17 00:00:00 2001 From: AdriVanHoudt Date: Mon, 16 Mar 2015 09:22:19 +0100 Subject: [PATCH 5/7] feedback patch // moved logic to lib index file // added hoek for err assertion // updated license // updated gitignore file (taken from hapi repo) --- .gitignore | 4 ++++ index.js | 32 +------------------------------- lib/index.js | 30 ++++++++++++++++++++++++++++++ package.json | 5 +++-- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index b0c272c..12db069 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ .idea *.iml npm-debug.log +dump.rdb node_modules +results.tap +results.xml +config.json .DS_Store */.DS_Store */*/.DS_Store diff --git a/index.js b/index.js index 5d91f66..bf4d18a 100644 --- a/index.js +++ b/index.js @@ -1,31 +1 @@ -var Hapi = require('hapi'); - -var internals = { - pkg: require('./package.json') -}; - -var server = new Hapi.Server(); - -server.connection({ port: process.env.PORT || 8000 }); - -server.route({ - method: 'GET', - path: '/version', - handler: function (request, reply) { - - return reply({ version: internals.pkg.version }); - }, - config: { - description: 'Returns the version of the server' - } -}); - -server.start(function (err) { - - if (err) { - throw err - } - - // once we have something like good-console we can use server.log here - console.log('Server started at: ' + server.info.uri); -}); +module.exports = require('./lib/index.js'); diff --git a/lib/index.js b/lib/index.js index e69de29..b78313c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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', + handler: function (request, reply) { + + return reply({ version: internals.pkg.version }); + }, + config: { + description: 'Returns the version of the server' + } +}); + +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); +}); diff --git a/package.json b/package.json index 9b27e00..a32d24a 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,13 @@ "hapi.js" ], "author": "Hueniversity students", - "license": "ISC", + "license": "BSD", "bugs": { "url": "https://github.com/hueniverse/hueniversity/issues" }, "homepage": "https://github.com/hueniverse/hueniversity", "dependencies": { - "hapi": "8.4.x" + "hapi": "8.4.x", + "hoek": "2.11.x" } } From 8ac5e6f1d331d7f1d20f52888065491eb085d0ee Mon Sep 17 00:00:00 2001 From: AdriVanHoudt Date: Mon, 16 Mar 2015 19:56:05 +0100 Subject: [PATCH 6/7] Moved handler to config --- lib/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index b78313c..ce486de 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,11 +12,11 @@ server.connection({ port: process.env.PORT || 8000 }); server.route({ method: 'GET', path: '/version', - handler: function (request, reply) { - - return reply({ version: internals.pkg.version }); - }, config: { + handler: function (request, reply) { + + return reply({ version: internals.pkg.version }); + }, description: 'Returns the version of the server' } }); From 95133ad532c6821153e74bcd25aace4e65f0c268 Mon Sep 17 00:00:00 2001 From: AdriVanHoudt Date: Mon, 16 Mar 2015 20:53:16 +0100 Subject: [PATCH 7/7] styling stuff --- index.js | 2 +- lib/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index bf4d18a..f3499bb 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./lib/index.js'); +require('./lib'); diff --git a/lib/index.js b/lib/index.js index ce486de..79f5b91 100644 --- a/lib/index.js +++ b/lib/index.js @@ -13,11 +13,11 @@ server.route({ method: 'GET', path: '/version', config: { + description: 'Returns the version of the server', handler: function (request, reply) { return reply({ version: internals.pkg.version }); - }, - description: 'Returns the version of the server' + } } });