var hapi = require('hapi'); var joi = require('joi'); 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+1 }); 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; console.log('Server running at:', server.info.uri); }); }