Skip to content

Instantly share code, notes, and snippets.

@ignivaravinderrikhi
Created October 24, 2016 12:52
Show Gist options
  • Save ignivaravinderrikhi/ef87d6309ace368d3c1fd3fe33c5fa80 to your computer and use it in GitHub Desktop.
Save ignivaravinderrikhi/ef87d6309ace368d3c1fd3fe33c5fa80 to your computer and use it in GitHub Desktop.
var server = new Hapi.Server();
server.connection({
host: app.host,
port: app.port
});
console.log("+++++++++++ SERVER SETTINGS LOADED +++++++++++\r\n" +JSON.stringify(app)+ "\n");
server.route(routes);
//index route
server.route([{
method: 'GET',
path: '/',
handler: function (request, reply){
return reply({
name: app.name,
endpoint: app.host,
port: app.port
}).code(201);
}
}]);
//Start the server
var options = {
info:{
'title':'SpiceMint API Documentation',
'version': '1.0.0'
},
pathPrefixSize: 2,
basePath: '/v1',
tags:[{
name: 'Inventory',
description: 'All APIs regarding inventory management'
},{
name: 'Merchant',
description: 'All APIs associated with the Merchant Module'
}]
},
goodOptions = {
ops: {
interval: 1000
},
reporters: {
myConsoleReporter: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{ log: '*', response: '*', request: '*' }]
}, {
module: 'good-console'
},
'stdout']
}
};
server.register([
Inert,
Vision,{
register : require('good'),
goodOptions
},{
'register': HapiSwagger,
'options': options
}
],function (err) {
server.start(function (err) {
if (err) {
console.log('+++++++++++++++++++++++ Error starting server +++++++++++++++++++++');
} else {
console.log('+++++++++++++++++++++++ SERVER STARTED +++++++++++++++++++++++++++ \r\nServer running at:' + server.info.uri);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment