Created
May 1, 2022 17:25
-
-
Save fracalo/e92a6a64cd139ec7e6823db2d4964a28 to your computer and use it in GitHub Desktop.
using on to wrap createServer (nodejs)
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
import http from 'http' | |
import { on } from 'events' | |
const server = http.createServer() | |
const requests = on(server.listen(3000), 'request') | |
for await (let req of requests) { | |
console.log('req', req) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment