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

refactor(version): use of plugin system #74

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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ config.json
*/._*
*/*/._*
coverage.*
.eslintrc
.editorconfig
22 changes: 7 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var Hapi = require('hapi');
var Hoek = require('hoek');
var Package = require('../package.json');
var Version = require('./version');


// Declare internals
Expand All @@ -14,24 +14,16 @@ internals.init = function () {

var server = new Hapi.Server();
server.connection({ port: 8000 });
server.register(Version, function(err) {

server.route({
method: 'GET',
path: '/version',
config: {
description: 'Returns the version of the server',
handler: function (request, reply) {
Hoek.assert(!err, err);
server.start(function (err) {

return reply({ version: Package.version });
}
}
Hoek.assert(!err, err);
console.log('Server started at: ' + server.info.uri);
});
});

server.start(function (err) {

Hoek.assert(!err, err);
console.log('Server started at: ' + server.info.uri);
});
};

internals.init();
22 changes: 22 additions & 0 deletions lib/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var Package = require('../package.json');

exports.register = function(server, options, next) {

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

return reply({ version: Package.version });
}
}
});

return next();
};

exports.register.attributes = {
name: 'version'
};
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"name": "hueniversity",
"version": "0.0.1",
"version": "0.0.2",
"description": "Community learning experiment",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/hueniverse/hueniversity.git"
"url": "https://github.com/hueniversity/hueniversity.git"
},
"keywords": [
"hapi",
"learn",
"community"
],
"author": "Tyler Briles",
"license": "BSD",
"bugs": {
"url": "https://github.com/hueniverse/hueniversity/issues"
"url": "https://github.com/hueniversity/hueniversity.git"
},
"homepage": "https://github.com/hueniverse/hueniversity",
"homepage": "https://github.com/hueniversity/hueniversity",
"dependencies": {
"hapi": "8.x.x",
"hoek": "2.x.x"
Expand Down