Skip to content

Commit

Permalink
assignment1
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-1 committed Dec 19, 2017
1 parent b819565 commit 25a6639
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';


// Load modules

const Hapi = require('hapi');
const Package = require('../package.json');


// Declare internals

const internals = {
response: {
version: Package.version
}
};

// Declare server options

const serverOptions = {
port: process.env.PORT || 8000
};


async function init() {

const server = new Hapi.Server(serverOptions);

const version = function (request, h) {

return internals.response
};

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

await server.start();

console.log('Server startd at: ' + server.info.uri);
console.log('Server started port:' + server.info.port);
};

init().then(() => {

console.log('post start');
}).catch((err) => {

// catch failed start up

console.log('server failed:!!! ' + err);
});

0 comments on commit 25a6639

Please sign in to comment.