Project Setup & the Current Express Baseline

Website Rebuild with Express

Chapter 1 · Project Setup & the Current Express Baseline

This is the sixth and truly final course in the Website Rebuild series, alongside the already-complete Next.js, Django, Laravel, Rails, and Astro rebuilds. It builds on this site's own existing express1/express2 courses and the Food Tracker (React + Express) project — this chapter assumes the language and the basic Express mental model are already familiar ground.

Scaffolding the Project

npm init -y npm install express ejs mysql2

The Minimal Server

// server.js const express = require('express'); const app = express(); app.set('view engine', 'ejs'); app.listen(3000, () => { console.log('Server running on http://localhost:3000'); });

Confirmed: The Most Minimal Framework in the Series

Even the templating engine isn't assumed
Every sibling in this series ships at least some opinion: Astro owns its own routing and rendering outright; Next.js, Django, Laravel, and Rails each bundle a real templating story by default. Express does none of this. app.set('view engine', 'ejs') is a literal, explicit statement — Express itself has no default rendering engine at all, and would run exactly the same way if this line named Pug, Handlebars, or Nunjucks instead. Nothing about "how views render" is Express's own opinion; it's entirely the developer's choice, stated once, in one line.

No ORM, No Routing Convention, No Session Handling

mysql2 is a plain database driver, not an ORM — Chapter 2 writes real SQL directly, continuing the same deliberate choice the Food Tracker (React + Express) course already made for this exact stack. Express's own routing is a thin method-chaining API (app.get(), app.post()) with no file-based or convention-driven routing at all — every route is registered by hand. Session handling, request validation, CSRF protection — none of it exists until a specific package is chosen and installed for it, chapter by chapter, starting here.

Six Frameworks, Compared Honestly

Next.jsDjangoLaravelRailsAstroExpress
Built-in ORM?NoYesYesYesNoNo
Built-in rendering engine?Yes (JSX)Yes (DTL)Yes (Blade)Yes (ERB)Yes (Astro syntax)No — chosen explicitly
Built-in routing convention?Yes — file-basedExplicit but built inExplicit but built inExplicit but built inYes — file-basedNo — hand-registered
Built-in session handling?NoYesYesYesNoNo
Coming in later chapters
No database schema, no routing, no session package, no validation library exists yet — every one of those gets built or chosen deliberately, starting with Chapter 2's own raw SQL schema.

Hands-On Exercises

Exercise 1

Scaffold a new Express project, and confirm a minimal "Hello World" route responds correctly at http://localhost:3000.

📄 View solution
Exercise 2

Remove app.set('view engine', 'ejs'), attempt to call res.render() from a route, and confirm Express has no default rendering engine to fall back on.

📄 View solution
Exercise 3

Inspect the freshly scaffolded project's package.json, and confirm nothing beyond express, ejs, and mysql2 exists yet — no ORM, no session library, no validation library.

📄 View solution

Chapter 1 Quick Reference

  • npm install express ejs mysql2 — the entire starting stack
  • app.set('view engine', 'ejs') — Express has no default templating engine at all
  • The most minimal framework in the series — no ORM, no routing convention, no session handling, no built-in rendering
  • mysql2 — a plain driver, not an ORM, continuing the Food Tracker (React + Express) course's own established choice
  • Next chapter: Designing a Flexible URL & Content Model