![]() ![]() Ditch the var 3.8 Require modules first, not inside functions 3.9 Set an explicit entry point to a module/folder □ #updated 3.9 Code example - avoid coupling the client to the module structure 3.10 Use the = operator 3.10 Code example 3.11 Use Async Await, avoid callbacks 3.12 Use arrow function expressions (=>) 3.13 Avoid effects outside of functions □ #new 4. Code Patterns And Style Practices 3.1 Use ESLint 3.2 Use Node.js eslint extension plugins □ #updated 3.3 Start a Codeblock's Curly Braces on the Same Line Code Example 3.4 Separate your statements properly Code example 3.5 Name your functions 3.6 Use naming conventions for variables, constants, functions and classes 3.6 Code Example 3.7 Prefer const over let. Error Handling Practices 2.1 Use Async-Await or promises for async error handling 2.2 Extend the built-in Error object □ #updated 2.3 Distinguish catastrophic errors from operational errors □ #updated 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 □ #updated 2.8 Test error flows using your favorite test framework □ #updated 2.9 Discover errors and downtime using APM products 2.10 Catch unhandled promise rejections □ #updated 2.11 Fail fast, validate arguments using a dedicated library 2.12 Always await promises before returning to avoid a partial stacktrace □ #new 2.13 Subscribe to event emitters and streams 'error' event □ #new 3. Project Architecture Practices 1.1 Structure your solution by business components □ #updated 1.2 Layer your components with 3-tiers, keep the web layer within its boundaries □ #updated 1.3 Wrap common utilities as packages, consider publishing 1.4 Use environment aware, secure and hierarchical config □ #updated 1.5 Consider all the consequences when choosing the main framework □ #new 1.6 Use TypeScript sparingly and thoughtfully □ #new 2. Hold on, I've just launched my beyond-the-basics testing course, which is on a □ limited-time sale until August 7th Table of Contents 1. Node.js Best Practices □ 2023 edition is here! Welcome! 3 Things You Ought To Know First By Yoni Goldberg Learn with me: As a consultant, I engage with worldwide teams on various activities like workshops and code reviews. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |