2016-10-22 22:35:32 +00:00
|
|
|
var hapi = require('hapi');
|
2016-10-20 21:58:56 +00:00
|
|
|
var cfg = require('../cfg/websrv.json');
|
2016-10-22 22:35:32 +00:00
|
|
|
|
|
|
|
const server = new hapi.Server();
|
2016-10-20 21:58:56 +00:00
|
|
|
|
|
|
|
var templates = {};
|
|
|
|
var lib;
|
|
|
|
|
|
|
|
module.exports = Websrv;
|
|
|
|
function Websrv(tlib) {
|
|
|
|
this.lib = lib = tlib;
|
|
|
|
|
2016-10-22 22:35:32 +00:00
|
|
|
server.connection({
|
|
|
|
port: cfg.port
|
|
|
|
});
|
2016-10-20 21:58:56 +00:00
|
|
|
|
2016-10-22 22:35:32 +00:00
|
|
|
server.route({
|
|
|
|
method: 'GET',
|
|
|
|
path: '/',
|
|
|
|
handler: function (req, reply) {
|
|
|
|
return reply('hello world');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
server.route({
|
|
|
|
method: 'GET',
|
|
|
|
path: '/{ID}',
|
|
|
|
handler: function (req, reply) {
|
|
|
|
return reply('ID: ' + encodeURIComponent(req.params.ID));
|
|
|
|
},
|
|
|
|
config: {
|
|
|
|
validate: {
|
|
|
|
params: {
|
|
|
|
ID: Joi.number()
|
2016-10-20 21:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-22 22:35:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
server.start((err) => {
|
|
|
|
if(err)
|
|
|
|
throw err;
|
|
|
|
lib.bot.send(lib.cfg.debugchannel, 'Server running at:', server.info.uri, 'n0xy');
|
|
|
|
});
|
|
|
|
}
|