Created
January 8, 2019 00:36
-
-
Save mfanto/9ffac7d26a26cd1649c9ff6810be9d73 to your computer and use it in GitHub Desktop.
hapi request example
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'); | |
const server = Hapi.server({ | |
port: 3000, | |
host: 'localhost' | |
}); | |
server.events.on({ name: 'request' }, (request, event, tags) => { | |
console.log(event.request); | |
console.log(tags); | |
}); | |
server.route({ | |
method: 'GET', | |
path: '/', | |
handler: () => { | |
return 'Hello, world!'; | |
} | |
}); | |
const init = async () => { | |
await server.start(); | |
console.log(`Server running at: ${server.info.uri}`); | |
}; | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment