Express: an API server

Lesson 05 · 9 min

Project structure

Routes apart, logic apart, database apart. Then the code is testable.

With one file everything is simple. When there are twenty routes, split the code by role: the router knows paths, the controller reads req and builds res, the service holds business logic and knows nothing about HTTP, the repository talks to the database.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.