diff --git a/app.js b/app.js index c6773be..27e8336 100755 --- a/app.js +++ b/app.js @@ -5,7 +5,9 @@ // Glenn Jones -var Hapi = require('hapi'), +var Hapi = require('@hapi/hapi'), + Inert = require('@hapi/inert'), + Good = require('@hapi/good'), Blipp = require('blipp'), Pack = require('./package'); @@ -15,7 +17,7 @@ var routes = [{ path: '/{path*}', handler: { directory: { - path: '/tests', + path: './tests', listing: true, index: false } @@ -45,40 +47,43 @@ var routes = [{ // Create a server with a host and port -var server = new Hapi.Server(); - -server.connection({ +var server = Hapi.server({ host: (process.env.PORT)? '0.0.0.0' : 'localhost', port: parseInt(process.env.PORT, 10) || 3008 }); -// hapi server settings -server.route(routes); - - var goodOptions = { - opsInterval: 1000, - reporters: [{ - reporter: require('good-console'), - events: { log: '*', response: '*' } - }] + ops: { interval: 1000 }, + reporters: { + console: [ + { module: '@hapi/good-squeeze', name: 'Squeeze', args: [{ log: '*', response: '*' }] }, + { module: '@hapi/good-console' }, + 'stdout' + ] + } }; -// Register plug-in and start -server.register([{ - register: require('good'), - options: goodOptions - },{ - register: require('blipp'), - }], function (err) { - if (err) { - console.error(err); - }else { - server.start(function () { - console.info('Server started at ' + server.info.uri); - }); - } - }); +// Register plug-ins and start +var init = async function () { + await server.register([ + Inert, + Blipp, + { plugin: Good, options: goodOptions } + ]); + + // hapi server settings + server.route(routes); + + await server.start(); + console.info('Server started at ' + server.info.uri); +}; + +process.on('unhandledRejection', function (err) { + console.error(err); + process.exit(1); +}); + +init(); diff --git a/interface.js b/interface.js index 3eff3a3..30e7176 100644 --- a/interface.js +++ b/interface.js @@ -7,7 +7,7 @@ if(require.main === module) { // if they want the app - var app = require('app.js'); + var app = require('./app.js'); }else{ // if they want a module interface var pack = require('./package.json'); diff --git a/package.json b/package.json index 7f0f5ce..45deab1 100644 --- a/package.json +++ b/package.json @@ -9,19 +9,18 @@ "url": "git://github.com/microformats/tests.git" }, "engines": { - "node": ">= 0.12.x" + "node": ">= 14.15.0" }, "main": "interface.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "devDependencies": { - "blipp": "2.1.x", - "boom": "2.7.x", - "good": "6.1.x", - "good-console": "5.0.x", - "handlebars": "4.0.x", - "hapi": "11.1.x", - "joi": "6.4.x" + "@hapi/good": "9.0.x", + "@hapi/good-console": "9.0.x", + "@hapi/good-squeeze": "6.0.x", + "@hapi/hapi": "21.4.x", + "@hapi/inert": "7.1.x", + "blipp": "4.0.x" } }