Last active
December 10, 2015 15:33
-
-
Save eduardonunesp/5fbb8f2187af3d10f621 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'; | |
import Hapi from 'hapi'; | |
import Promise from 'bluebird'; | |
const server = new Hapi.Server(); | |
server.register([ | |
require('hapi-async-handler') | |
], function(error) { | |
if (error) { | |
console.error('Error while register handler', error); | |
} | |
}); | |
server.connection({ | |
port: 3000 | |
}); | |
const default_handler = async function (request, reply) { | |
await Promise.delay(1000); | |
reply('Hello, ok'); | |
}; | |
server.route({ | |
method: 'GET', | |
path: '/', | |
handler: { | |
async: default_handler | |
} | |
}); | |
server.start(() => { | |
console.log(`Server running at: ${server.info.uri}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment