Skip to content

Instantly share code, notes, and snippets.

@rtrys
Last active August 12, 2020 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtrys/d7a4b3ad586654f129eea9ee64b9a1fd to your computer and use it in GitHub Desktop.
Save rtrys/d7a4b3ad586654f129eea9ee64b9a1fd to your computer and use it in GitHub Desktop.
'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