Architecture is mostly about which code is allowed to know what. Business rules shouldn't know about HTTP, databases or email; the edges of the application translate between those and the rules.
These tasks build four common boundaries in TypeScript. A Result type makes failure part of a function's return value, so one bad line in an import is reported instead of aborting it. A port (an interface) lets a reservation rule run against an in-memory adapter in tests and a database adapter in production. Domain errors are classes that describe business problems, and only the edge maps them to status codes. An event bus lets modules react to an order without importing each other, and keeps one failing module from stopping the rest.
Node.js services, with routing, middleware and real I/O, are the separate Node.js services course (DF-P77).
A discriminated union makes the caller handle both outcomes.