Created
February 24, 2020 21:58
-
-
Save ejnshtein/371823253a7e4b65dfe9c7b3f6e713c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const Express = require('express') | |
const app = Express() | |
const sleep = timeout => new Promise(resolve => setTimeout(resolve, timeout)) | |
async function getData () { | |
await sleep(400) | |
return 1 | |
} | |
async function processData (data) { | |
await sleep(200) | |
return data * 2 | |
} | |
app.get('/', async function (request, reply) { | |
const data = await getData() | |
const processed = await processData(data) | |
return processed | |
}) | |
app.listen(3000, err => { | |
console.log(err || 'listening...') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment