The document discusses ExpressJS, the most popular Node.js web application framework. It notes that ExpressJS is easy to get started with but may lack experience to fully understand needs. The document then covers key aspects of ExpressJS like routing, middleware, and default architecture. It proposes different schemas and approaches for cleaning out and separating concerns in ExpressJS applications, such as using entity loaders, data mappers, validators, and controlling flow through events rather than direct method calls.
3. - Express.js is the most popular Node.js web application framework used
today
- Not enough experience to understand our needs
- Easy to jump in
Why did we choose ExpressJS?
12. ExpressJS: Clean Controller
problem of overusing
const controller = {
};
Data Validators
Access Control
Entity Loaders
Data Mappers
Business Logic
13. validator
middleware
entity loader access control data mapper controller
middleware middleware middleware middleware
ExpressJS: Clean Controller
cleaning out - short flow schema
14. - Load data from source (database)
- Modify request by assigning loaded data to access it from controller
ExpressJS: Clean Controller
cleaning out - entity loader schema
15. ExpressJS: Clean Controller
cleaning out - full flow schema
error error error
success success success success
errorerror
success
validator entity loader
access
control
data mapper controller
top level error handler
request response
17. ExpressJS: Clean Controller
cleaning out - using events
Event handler
Module A Module B Module C Controller
request response
“Background” functionality