Section 2 · Node & Express

JavaScript, now on the server

Node lets JavaScript run outside the browser. Express is a tiny framework that makes building a web server easy.

🎯 In one line: Node runs JS on a server; Express is a small library that turns a handful of lines into a working web server.

1Node.js — the same language, a new home

You already know JavaScript. Node.js is a program that runs JavaScript on a computer instead of in a browser — so you can use the same language to build servers. That's a superpower: one language, whole app.

# you write a file server.js, then run it with Node:
node server.js
# it keeps running, listening for requests

2Express — a web server in 6 lines

Raw Node can make a server, but it's clunky. Express is the standard framework that makes it clean:

const express = require("express");   // 1. bring in Express
const app = express();                // 2. make an app

app.get("/", (req, res) => {          // 3. when someone visits "/"
  res.send("Hello from the server!"); //    send this back
});

app.listen(4000, () => {              // 4. start listening on port 4000
  console.log("Server running on http://localhost:4000");
});
Read it in plain words "Make an app. When a GET request hits /, run this function and send a reply. Start listening on port 4000." That's a real, working web server. Everything else is just more routes.

3req and res — the two objects you'll always see

ObjectIsYou use it to…
req (request)what the client sentread the URL, the body (req.body), params (req.params.id)
res (response)what you send backreply with data: res.json(notes), res.status(404)
💡 Every route handler is (req, res) => { ... }: read what came in from req, send an answer with res. Master those two and you've mastered Express.

4Getting it running (the real steps)

mkdir notes-server && cd notes-server
npm init -y            # create a package.json
npm install express    # download Express
node server.js         # run it → "Server running on http://localhost:4000"
🧠

Quick check

1. What is Node.js?
Node runs JS on a server — so the same language powers both frontend and backend.
2. In app.get("/", (req, res) => ...), what is res for?
res is the response — res.json(...), res.send(...) send data back.
3. Express is…
Express turns a few lines into a working HTTP server with clean routing.
🔓 You're reading a free chapter of Backend (Node) — the first two are open.
Unlock the rest of this course with a one-time payment.
Unlock this course →
🔓 See course prices