Skip to content

Latest commit

 

History

History
119 lines (72 loc) · 1.73 KB

07_Response_Normalization_Strategies.md

File metadata and controls

119 lines (72 loc) · 1.73 KB

[Stephen Grider] Microservices with Node JS and React [ENG, 2020]

07. Response Normalization Strategies


01. Creating Route Handlers


02. Scaffolding Routes


03. Adding Validation

$ cd app/auth
$ npm install --save express-validator

04. Handling Validation Errors

$ curl \
--data '{"email":"notValidEmail", "password":"1"}' \
--header "Content-Type: application/json" \
--request POST http://ticketing.dev/api/users/signup \
| python -m json.tool

response:

[
    {
        "location": "body",
        "msg": "Email must be valid",
        "param": "email",
        "value": "notValidEmail"
    },
    {
        "location": "body",
        "msg": "Password must be between 4 and 20 characters",
        "param": "password",
        "value": "1"
    }
]

06. Surprising Complexity Around Errors


07. Other Sources of Errors


08. Solution for Error Handling


09. Building an Error Handling Middleware


10. Communicating More Info to the Error Handler


11. Encoding More Information In an Error


12. Subclassing for Custom Errors


13. Determining Error Type


14. Converting Errors to Responses


15. Moving Logic Into Errors


16. Verifying Our Custom Errors


17. Final Error Related Code


18. How to Define New Custom Errors


19. Uh Oh... Async Error Handling

$ cd app/auth
$ npm install --save express-async-errors



Marley

Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат