HomeChallengesRepsProblemsLeaderboardTake a challenge

Routes, controllers and types across files

app.ts does everything: data, handlers, routes and wiring, in one long file. Split it so each part has one job — handlers in the controller, routes in a router, and app.ts only wiring — without changing a single response.

Intermediate10 min on the clock5 graded checks · 100 pointsTyped Express
Graded by running your code against real cases.

What you build

  • Move the handlers into orders.controller.ts as typed RequestHandlers
  • Create ordersRouter in orders.router.ts with routes relative to its mount
  • Mount it in app.ts with app.use("/orders", ordersRouter)
  • Keep app.ts under 25 lines, and every response the same

Done means

Every response unchanged, handlers typed in the controller, a logic-free router with relative paths, and a short app.ts.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. Every response is unchanged+35Where code lives
  2. app.ts only wires things together+15Where code lives
  3. Handlers are typed RequestHandlers+20Generics that keep the caller’s type
  4. The router holds routes, not logic+15Where code lives
  5. Router paths are relative to the mount+15Where code lives

What it teaches

Generics that keep the caller’s typeadvanced

A generic function takes its types as parameters, so one function serves menu items, orders and customers while handing each caller back its own type — where any would hand back nothing the compiler can check.

The rest of Typed Express