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

Assignment 1 #28

Closed
wants to merge 8 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
**/*~
*.log
52 changes: 52 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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);
});
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}