Skip to content

Instantly share code, notes, and snippets.

@fracalo
Created May 1, 2022 17:25
Show Gist options
  • Save fracalo/e92a6a64cd139ec7e6823db2d4964a28 to your computer and use it in GitHub Desktop.
Save fracalo/e92a6a64cd139ec7e6823db2d4964a28 to your computer and use it in GitHub Desktop.
using on to wrap createServer (nodejs)
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