diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..29a3c69 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +**/*~ +*.log \ No newline at end of file diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..2bed187 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,52 @@ +'use strict'; + +// Index for basic http server + +// Dependencies +var Hapi = require('hapi'); +var Hoek = require('hoek'); + +// Internal objects +var internals = {}; + +// Add pkg to internals +if (!internals.hasOwnProperty('pkg')){ + + internals = { + pkg: require('../package.json') + } +} + +// Create a server +var server = new Hapi.Server(); + +// Creates a connection +server.connection({ port: process.env.PORT || 8000 }); + +// Routes +server.route({ + method: 'GET', + path: '/version', + config: { + description: 'Get version of the application', + + handler: function(request, reply){ + + // Preparing the response + var response = { + version: internals.pkg.version + } + + return reply(response); + } + } +}); + + +server.start(function(err){ + + Hoek.assert(!err, err); + + // Log the running server + console.log('Server is running at ' + server.info.uri); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..4fa008d --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "hueniversity", + "version": "0.0.1", + "description": "Communitiy learning experiment", + "main": "index.js", + "scripts": { + "start": "node ./lib/index.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/hueniverse/hueniversity.git" + }, + "keywords": [ + "hapi", + "hapijs" + ], + "author": "Community", + "license": "BSD", + "bugs": { + "url": "https://github.com/hueniverse/hueniversity/issues" + }, + "homepage": "https://github.com/hueniverse/hueniversity", + "dependencies": { + "hapi": "^8.4.0", + "hoek": "^2.11.1" + } +}