Skip to content

Node/Express Pocket Map

Driving at 100mph doesn’t leave much time to read documentation. Keep this map in your glovebox.

A glowing, holographic roadmap floating above a dashboard. Neons lines trace the routes of Express. Key landmarks like 'Router', 'Middleware', and 'Static' are marked as transit stops.

Fig 1: Your Guide to the Node.js Galaxy (and Express).


const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Driving on ${PORT}`));
MethodSyntaxUse Case
GETapp.get('/path', handler)Read/Retrieve
POSTapp.post('/path', handler)Create/Send
PUTapp.put('/path', handler)Update (Replace)
DELETEapp.delete('/path', handler)Destroy
Catch-Allapp.all('*', handler)404/Dead Ends
  • Route Params: /users/:id -> req.params.id
  • Query Strings: /search?q=foo -> req.query.q
  • Headers: req.get('Content-Type')
  • res.send("Text"): Quick text/HTML.
  • res.json({ id: 1 }): API Data (Standard).
  • res.sendFile("/abs/path/file.html"): Serve file.
  • res.status(404): Set status code.
// 1. Write it
const check = (req, res, next) => {
if (ok) next();
else res.status(403).send('No');
};
// 2. Use it (Global)
app.use(check);
// 3. Use it (Route)
app.get('/safe', check, handler);

📘 Intro to Express.js Study Guide (PDF)

Express.js Github Repo

Express All In One Lifeline App - Demo Repo

⏭ Next Stop:

Rev up your templating engines.