Skip to content

Commit

Permalink
sever also uses event emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanupam1001 committed Aug 21, 2023
1 parent 559ac8b commit 25aa763
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 17-server-event-emitter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const http = require('http')

/*
const server = http.createServer((req, res) => {
res.end('Hello')
})
server.listen(5000)
*/

// using Event Emitter API

const server = http.createServer()
// emits request event

// subscribe to it / listen for it / respond to it
server.on('request', (req, res) => {
res.end('Hello')
})

server.listen(5000)

0 comments on commit 25aa763

Please sign in to comment.