Last active
August 12, 2020 01:38
-
-
Save rtrys/d7a4b3ad586654f129eea9ee64b9a1fd to your computer and use it in GitHub Desktop.
This file contains 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
'use strict'; | |
const hapi = require('@hapi/hapi'); | |
async function main() { | |
try { | |
const server = await hapi.server(); | |
await server.register({ | |
plugin: require('hapi-pino'), | |
options: { | |
ignorePaths: [ | |
'/some/path', | |
], | |
}, | |
}); | |
const request = { method: 'POST', url: 'http://(a|b).loclhost:80a/' }; | |
const res = await server.inject(request); | |
console.log('-----------------'); | |
console.log(res.request.response._error); | |
console.log('-----------------'); | |
// if inject an invalid URL makes node crash | |
// we are unable to start hapi, if not we | |
// can start hapi successfully | |
await server.start(); | |
server.logger.info('Server running on %s', server.info.uri); | |
} catch (e) { | |
console.error(e); | |
process.exit(1); | |
} | |
} | |
process.on('unhandledRejection', (err) => { | |
console.error(err); | |
process.exit(1); | |
}); | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment