Skip to content

⭐ Routes

Terrence Daniels edited this page Aug 14, 2026 · 1 revision

7 route files — pure wiring, so the meaningful test for each is a real HTTP request through the actual middleware chain (verifyToken → controller → errorHandler) via supertest, not introspecting Express's internal router or re-testing controller logic already covered elsewhere.

This layer is also where this repo worked out its .ts-requiring-.ts interop rules the hard way, one real runtime failure at a time:

  • import x = require("./y") typechecks fine but still compiles to a plain require() call underneath — and plain Node require() cannot resolve a .ts extension no matter how it's spelled in TypeScript. A real ES import x from "./y" is what actually works, since Vite/esbuild's resolver (used for genuine import statements) understands extensionless .ts resolution natively.
  • A module built with export = {...} can only ever be referenced via a default import, never a named one — import { getProfile } from "..." is an outright type error, regardless of what the object looks like at runtime.
  • require.resolve(...) inside a test's cache-eviction helper only makes sense for genuinely-.js siblings. A .ts sibling doesn't belong in that manual eviction list at all — vi.resetModules() already handles it as part of Vitest's own module graph.

A route-ordering regression test also lives here: GET /feed must not be shadowed by GET /:slug — confirmed it isn't, since /feed is registered first.

Clone this wiki locally