Improvements Overview
Discover how to enhance TypeScript applications by applying functional programming principles such as pure functions, immutability, and meaningful error handling. Learn to organize code for better maintainability through layering, better use of types, and splitting configuration and business logic for clearer separation of concerns.
Overview
How this application could be improved falls into two categories, namely general advice that should be applicable to any type of code and advice related to Functional Programming.
First, regarding the framework and its parameters, we should pass such parameters to as few functions as possible. We’ll want to keep everything related to receiving and responding as close as possible to the surface of the application. This content should appear in the outer layer of a hexagonal architecture. In a layered architecture, these concerns should only appear in the controller but never in the underlying service or database layers. This makes a large part of our application easier to understand and test.
FP helps with its focus on pure functions and ...