Error Handling Practices 2.1 Use Async-Await or promises for async error handling 2.2 Extend the built-in Error object 2.3 Distinguish catastrophic errors from operational errors 2.4 Handle errors centrally, not within a middleware 2.5 Document API errors using OpenAPI or GraphQL 2.6 Exit the process gracefully when a stranger comes to town 2.7 Use a mature logger to increase errors visibility 2.8 Test error flows using your favorite test framework 2.9 Discover errors and downtime using APM products 2.10 Catch unhandled promise rejections 2.11 Fail fast, validate arguments using a dedicated library 2.12 Always await promises before returning to avoid a partial stacktrace 3. Project Architecture Practices 1.1 Structure your solution by business components 1.2 Layer your components with 3-tiers, keep the web layer within its boundaries 1.3 Wrap common utilities as packages, consider publishing 1.4 Use environment aware, secure and hierarchical config 1.5 Consider all the consequences when choosing the main framework 1.6 Use TypeScript sparingly and thoughtfully 2. Or just it to learn by code examples Latest Best Practices and News Welcome! 3 Things You Ought To Know First Table of Contents 1. Use it to generate a new solution skeleton with all the practices baked inside. Node.js Best Practices □ We have an official Node.js starter - Practica.js.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |