Express js clean-controller

Preview:

Citation preview

Unnamed ProjectOriginal faults and profits

ExpressJS: Disposable Hero

- 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?

ExpressJS: Default architecture

- Routing

- Middlewares

ExpressJS: Key points

ExpressJS: Clean Controllerproblem of overusing

ExpressJS: Clean Controllerproblem of overusing

Data Validators

ExpressJS: Clean Controllerproblem of overusing

Data Validators

Entity Loaders

ExpressJS: Clean Controllerproblem of overusing

Data Validators

Access Control

Entity Loaders

ExpressJS: Clean Controllerproblem of overusing

Data Validators

Access Control

Entity Loaders

Data Mappers

ExpressJS: Clean Controllerproblem of overusing

Data Validators

Access Control

Entity Loaders

Data Mappers

Business Logic

ExpressJS: Clean Controllerproblem of overusing

const controller = {

};

Data Validators

Access Control

Entity Loaders

Data Mappers

Business Logic

validator

middleware

entity loader

access control

data mapper

controller

middleware middleware middleware middleware

ExpressJS: Clean Controllercleaning out - short flow schema

- Load data from source (database)

- Modify request by assigning loaded data to access it from controller

ExpressJS: Clean Controllercleaning out - entity loader schema

ExpressJS: Clean Controllercleaning 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

ExpressJS: Clean Controllercleaning out

ExpressJS: Clean Controllercleaning out - using events

Event handler

Module A Module B Module C Controller

request response“Background” functionality

Name: Roman SachenkoEmail: roman.sachenko@gmail.comSkype: roman.sachenko

DA - 14 2016

Recommended