var hapi = require('hapi'); var cfg = require('../cfg/websrv.json'); const server = new hapi.Server(); var templates = {}; var lib; module.exports = Websrv; function Websrv(tlib) { this.lib = lib = tlib; server.connection({ port: cfg.port }); 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() } } } }); server.start((err) => { if(err) throw err; lib.bot.send(lib.cfg.debugchannel, 'Server running at:', server.info.uri, 'n0xy'); }); }