Ev's Blog

Restarting my blogging career one commit at a time

How to write a simple router in Node.js

Saturday, October 15, 2022

And here is how you do the same thing that we did in Deno and Bun written for Node.js.

const http = require('http')

http.createServer(function (req, res) {
  if (req.url == '/ev') {
    res.end('Oh hey Ev!')
  } else {
    res.end('Hello from Node!')
  }
}).listen(3000)

Can you tell me a little more about why this example is different?