Created
October 24, 2016 12:52
-
-
Save ignivaravinderrikhi/ef87d6309ace368d3c1fd3fe33c5fa80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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