mirror of
https://github.com/goldbergyoni/nodebestpractices.git
synced 2025-10-29 00:19:14 +08:00
Reverted sub headers to previous markdown (from html to md)
This commit is contained in:
218
README.md
218
README.md
@ -55,11 +55,11 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#1-project-structure-practices">1. Project Structure Practices (5)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-11-structure-your-solution-by-components">1.1 Structure your solution by components</a> `#strategic`</br>
|
||||
  <a href="#-12-layer-your-components-keep-the-web-layer-within-its-boundaries">1.2 Layer your components, keep the web layer within its boundaries</a></br>
|
||||
  <a href="#-13-wrap-common-utilities-as-npm-packages">1.3 Wrap common utilities as npm packages</a> `#new`</br>
|
||||
  <a href="#-14-separate-express-app-and-server">1.4 Separate Express 'app' and 'server'</a></br>
|
||||
  <a href="#-15-use-environment-aware-secure-and-hierarchical-config">1.5 Use environment aware, secure and hierarchical config</a>🏷 `#advanced`</br>
|
||||
  [1.1 Structure your solution by components](#-11-structure-your-solution-by-components)</br>
|
||||
  [1.2 Layer your components, keep the web layer within its boundaries](#-12-layer-your-components-keep-the-web-layer-within-its-boundaries)</br>
|
||||
  [1.3 Wrap common utilities as npm packages](#-13-wrap-common-utilities-as-npm-packages)</br>
|
||||
  [1.4 Separate Express 'app' and 'server'](#-14-separate-express-app-and-server)</br>
|
||||
  [1.5 Use environment aware, secure and hierarchical config](#-15-use-environment-aware-secure-and-hierarchical-config)</br>
|
||||
|
||||
</details>
|
||||
|
||||
@ -68,18 +68,18 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#2-error-handling-practices">2. Error Handling Practices (12)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-21-use-async-await-or-promises-for-async-error-handling">2.1 Use Async-Await or promises for async error handling</a></br>
|
||||
  <a href="#-22-use-only-the-built-in-error-object">2.2 Use only the built-in Error object</a></br>
|
||||
  <a href="#-23-distinguish-operational-vs-programmer-errors">2.3 Distinguish operational vs programmer errors</a></br>
|
||||
  <a href="#-24-handle-errors-centrally-not-within-a-middleware">2.4 Handle errors centrally, not within a middleware</a></br>
|
||||
  <a href="#-25-document-api-errors-using-swagger-or-graphql">2.5 Document API errors using Swagger or GraphQL</a></br>
|
||||
  <a href="#-26-exit-the-process-gracefully-when-a-stranger-comes-to-town">2.6 Exit the process gracefully when a stranger comes to town</a></br>
|
||||
  <a href="#-27-use-a-mature-logger-to-increase-error-visibility">2.7 Use a mature logger to increase error visibility</a></br>
|
||||
  <a href="#-28-test-error-flows-using-your-favorite-test-framework">2.8 Test error flows using your favorite test framework</a></br>
|
||||
  <a href="#-29-discover-errors-and-downtime-using-apm-products">2.9 Discover errors and downtime using APM products</a></br>
|
||||
  <a href="#-210-catch-unhandled-promise-rejections">2.10 Catch unhandled promise rejections</a></br>
|
||||
  <a href="#-211-fail-fast-validate-arguments-using-a-dedicated-library">2.11 Fail fast, validate arguments using a dedicated library</a></br>
|
||||
  <a href="#-212-always-await-promises-before-returning-to-avoid-a-partial-stacktrace">2.12 Always await promises before returning to avoid a partial stacktrace</a></br>
|
||||
  [2.1 Use Async-Await or promises for async error handling](#-21-use-async-await-or-promises-for-async-error-handling)</br>
|
||||
  [2.2 Use only the built-in Error object](#-22-use-only-the-built-in-error-object)</br>
|
||||
  [2.3 Distinguish operational vs programmer errors](#-23-distinguish-operational-vs-programmer-errors)</br>
|
||||
  [2.4 Handle errors centrally, not within a middleware](#-24-handle-errors-centrally-not-within-a-middleware)</br>
|
||||
  [2.5 Document API errors using Swagger or GraphQL](#-25-document-api-errors-using-swagger-or-graphql)</br>
|
||||
  [2.6 Exit the process gracefully when a stranger comes to town](#-26-exit-the-process-gracefully-when-a-stranger-comes-to-town)</br>
|
||||
  [2.7 Use a mature logger to increase error visibility](#-27-use-a-mature-logger-to-increase-error-visibility)</br>
|
||||
  [2.8 Test error flows using your favorite test framework](#-28-test-error-flows-using-your-favorite-test-framework)</br>
|
||||
  [2.9 Discover errors and downtime using APM products](#-29-discover-errors-and-downtime-using-apm-products)</br>
|
||||
  [2.10 Catch unhandled promise rejections](#-210-catch-unhandled-promise-rejections)</br>
|
||||
  [2.11 Fail fast, validate arguments using a dedicated library](#-211-fail-fast-validate-arguments-using-a-dedicated-library)</br>
|
||||
  [2.12 Always await promises before returning to avoid a partial stacktrace](#-212-always-await-promises-before-returning-to-avoid-a-partial-stacktrace)</br>
|
||||
|
||||
</details>
|
||||
|
||||
@ -88,18 +88,18 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#3-code-style-practices">3. Code Style Practices (12)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-31-use-eslint">3.1 Use ESLint</a></br>
|
||||
  <a href="#-32-nodejs-specific-plugins">3.2 Node.js specific plugins</a></br>
|
||||
  <a href="#-33-start-a-codeblocks-curly-braces-on-the-same-line">3.3 Start a Codeblock's Curly Braces on the Same Line</a></br>
|
||||
  <a href="#-34-separate-your-statements-properly">3.4 Separate your statements properly</a></br>
|
||||
  <a href="#-35-name-your-functions">3.5 Name your functions</a></br>
|
||||
  <a href="#-36-use-naming-conventions-for-variables-constants-functions-and-classes">3.6 Use naming conventions for variables, constants, functions and classes</a></br>
|
||||
  <a href="#-37-prefer-const-over-let-ditch-the-var">3.7 Prefer const over let. Ditch the var</a></br>
|
||||
  <a href="#-38-require-modules-first-not-inside-functions">3.8 Require modules first, not inside functions</a></br>
|
||||
  <a href="#-39-require-modules-by-folders-as-opposed-to-the-files-directly">3.9 Require modules by folders, as opposed to the files directly</a></br>
|
||||
  <a href="#-310-use-the--operator">3.10 Use the === operator</a></br>
|
||||
  <a href="#-311-use-async-await-avoid-callbacks">3.11 Use Async Await, avoid callbacks</a></br>
|
||||
  <a href="#-312-use-arrow-function-expressions-">3.12 Use arrow function expressions (=>)</a></br>
|
||||
  [3.1 Use ESLint](#-31-use-eslint)</br>
|
||||
  [3.2 Node.js specific plugins](#-32-nodejs-specific-plugins)</br>
|
||||
  [3.3 Start a Codeblock's Curly Braces on the Same Line](#-33-start-a-codeblocks-curly-braces-on-the-same-line)</br>
|
||||
  [3.4 Separate your statements properly](#-34-separate-your-statements-properly)</br>
|
||||
  [3.5 Name your functions](#-35-name-your-functions)</br>
|
||||
  [3.6 Use naming conventions for variables, constants, functions and classes](#-36-use-naming-conventions-for-variables-constants-functions-and-classes)</br>
|
||||
  [3.7 Prefer const over let. Ditch the var](#-37-prefer-const-over-let-ditch-the-var)</br>
|
||||
  [3.8 Require modules first, not inside functions](#-38-require-modules-first-not-inside-functions)</br>
|
||||
  [3.9 Require modules by folders, as opposed to the files directly](#-39-require-modules-by-folders-as-opposed-to-the-files-directly)</br>
|
||||
  [3.10 Use the === operator](#-310-use-the--operator)</br>
|
||||
  [3.11 Use Async Await, avoid callbacks](#-311-use-async-await-avoid-callbacks)</br>
|
||||
  [3.12 Use arrow function expressions (=>)](#-312-use-arrow-function-expressions-)</br>
|
||||
|
||||
</details>
|
||||
|
||||
@ -108,19 +108,19 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#4-testing-and-overall-quality-practices">4. Testing And Overall Quality Practices (13)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-41-at-the-very-least-write-api-component-testing">4.1 At the very least, write API (component) testing</a></br>
|
||||
  <a href="#-42-include-3-parts-in-each-test-name">4.2 Include 3 parts in each test name</a></br>
|
||||
  <a href="#-43-structure-tests-by-the-aaa-pattern">4.3 Structure tests by the AAA pattern</a></br>
|
||||
  <a href="#-44-detect-code-issues-with-a-linter">4.4 Detect code issues with a linter</a></br>
|
||||
  <a href="#-45-avoid-global-test-fixtures-and-seeds-add-data-per-test">4.5 Avoid global test fixtures and seeds, add data per-test</a></br>
|
||||
  <a href="#-46-constantly-inspect-for-vulnerable-dependencies">4.6 Constantly inspect for vulnerable dependencies</a></br>
|
||||
  <a href="#-47-tag-your-tests">4.7 Tag your tests</a></br>
|
||||
  <a href="#-48-check-your-test-coverage-it-helps-to-identify-wrong-test-patterns">4.8 Check your test coverage, it helps to identify wrong test patterns</a></br>
|
||||
  <a href="#-49-inspect-for-outdated-packages">4.9 Inspect for outdated packages</a></br>
|
||||
  <a href="#-410-use-production-like-environment-for-e2e-testing">4.10 Use production-like environment for e2e testing</a></br>
|
||||
  <a href="#-411-refactor-regularly-using-static-analysis-tools">4.11 Refactor regularly using static analysis tools</a></br>
|
||||
  <a href="#-412-carefully-choose-your-ci-platform-jenkins-vs-circleci-vs-travis-vs-rest-of-the-world">4.12 Carefully choose your CI platform (Jenkins vs CircleCI vs Travis vs Rest of the world)</a></br>
|
||||
  <a href="#-413-test-your-middlewares-in-isolation">4.13 Test your middlewares in isolation</a></br>
|
||||
  [4.1 At the very least, write API (component) testing](#-41-at-the-very-least-write-api-component-testing)</br>
|
||||
  [4.2 Include 3 parts in each test name](#-42-include-3-parts-in-each-test-name)</br>
|
||||
  [4.3 Structure tests by the AAA pattern](#-43-structure-tests-by-the-aaa-pattern)</br>
|
||||
  [4.4 Detect code issues with a linter](#-44-detect-code-issues-with-a-linter)</br>
|
||||
  [4.5 Avoid global test fixtures and seeds, add data per-test](#-45-avoid-global-test-fixtures-and-seeds-add-data-per-test)</br>
|
||||
  [4.6 Constantly inspect for vulnerable dependencies](#-46-constantly-inspect-for-vulnerable-dependencies)</br>
|
||||
  [4.7 Tag your tests](#-47-tag-your-tests)</br>
|
||||
  [4.8 Check your test coverage, it helps to identify wrong test patterns](#-48-check-your-test-coverage-it-helps-to-identify-wrong-test-patterns)</br>
|
||||
  [4.9 Inspect for outdated packages](#-49-inspect-for-outdated-packages)</br>
|
||||
  [4.10 Use production-like environment for e2e testing](#-410-use-production-like-environment-for-e2e-testing)</br>
|
||||
  [4.11 Refactor regularly using static analysis tools](#-411-refactor-regularly-using-static-analysis-tools)</br>
|
||||
  [4.12 Carefully choose your CI platform (Jenkins vs CircleCI vs Travis vs Rest of the world)](#-412-carefully-choose-your-ci-platform-jenkins-vs-circleci-vs-travis-vs-rest-of-the-world)</br>
|
||||
  [4.13 Test your middlewares in isolation](#-413-test-your-middlewares-in-isolation)</br>
|
||||
|
||||
</details>
|
||||
|
||||
@ -129,25 +129,25 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#5-going-to-production-practices">5. Going To Production Practices (19)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-51-monitoring">5.1. Monitoring</a></br>
|
||||
  <a href="#-52-increase-transparency-using-smart-logging">5.2. Increase transparency using smart logging</a></br>
|
||||
  <a href="#-53-delegate-anything-possible-eg-gzip-ssl-to-a-reverse-proxy">5.3. Delegate anything possible (e.g. gzip, SSL) to a reverse proxy</a></br>
|
||||
  <a href="#-54-lock-dependencies">5.4. Lock dependencies</a></br>
|
||||
  <a href="#-55-guard-process-uptime-using-the-right-tool">5.5. Guard process uptime using the right tool</a></br>
|
||||
  <a href="#-56-utilize-all-cpu-cores">5.6. Utilize all CPU cores</a></br>
|
||||
  <a href="#-57-create-a-maintenance-endpoint">5.7. Create a ‘maintenance endpoint’</a></br>
|
||||
  <a href="#-58-discover-errors-and-downtime-using-apm-products">5.8. Discover errors and downtime using APM products</a></br>
|
||||
  <a href="#-59-make-your-code-production-ready">5.9. Make your code production-ready</a></br>
|
||||
  <a href="#-510-measure-and-guard-the-memory-usage">5.10. Measure and guard the memory usage</a></br>
|
||||
  <a href="#-511-get-your-frontend-assets-out-of-node">5.11. Get your frontend assets out of Node</a></br>
|
||||
  <a href="#-512-be-stateless-kill-your-servers-almost-every-day">5.12. Be stateless, kill your servers almost every day</a></br>
|
||||
  <a href="#-513-use-tools-that-automatically-detect-vulnerabilities">5.13. Use tools that automatically detect vulnerabilities</a></br>
|
||||
  <a href="#-514-assign-a-transaction-id-to-each-log-statement">5.14. Assign a transaction id to each log statement</a></br>
|
||||
  <a href="#-515-set-node_envproduction">5.15. Set NODE_ENV=production</a></br>
|
||||
  <a href="#-516-design-automated-atomic-and-zero-downtime-deployments">5.16. Design automated, atomic and zero-downtime deployments</a></br>
|
||||
  <a href="#-517-use-an-lts-release-of-nodejs">5.17. Use an LTS release of Node.js</a></br>
|
||||
  <a href="#-518-dont-route-logs-within-the-app">5.18. Don't route logs within the app</a></br>
|
||||
  <a href="#-519-install-your-packages-with-npm-ci">5.19. Install your packages with npm ci</a></br>
|
||||
  [5.1. Monitoring](#-51-monitoring)</br>
|
||||
  [5.2. Increase transparency using smart logging](#-52-increase-transparency-using-smart-logging)</br>
|
||||
  [5.3. Delegate anything possible (e.g. gzip, SSL) to a reverse proxy](#-53-delegate-anything-possible-eg-gzip-ssl-to-a-reverse-proxy)</br>
|
||||
  [5.4. Lock dependencies](#-54-lock-dependencies)</br>
|
||||
  [5.5. Guard process uptime using the right tool](#-55-guard-process-uptime-using-the-right-tool)</br>
|
||||
  [5.6. Utilize all CPU cores](#-56-utilize-all-cpu-cores)</br>
|
||||
  [5.7. Create a ‘maintenance endpoint’](#-57-create-a-maintenance-endpoint)</br>
|
||||
  [5.8. Discover errors and downtime using APM products](#-58-discover-errors-and-downtime-using-apm-products)</br>
|
||||
  [5.9. Make your code production-ready](#-59-make-your-code-production-ready)</br>
|
||||
  [5.10. Measure and guard the memory usage](#-510-measure-and-guard-the-memory-usage)</br>
|
||||
  [5.11. Get your frontend assets out of Node](#-511-get-your-frontend-assets-out-of-node)</br>
|
||||
  [5.12. Be stateless, kill your servers almost every day](#-512-be-stateless-kill-your-servers-almost-every-day)</br>
|
||||
  [5.13. Use tools that automatically detect vulnerabilities](#-513-use-tools-that-automatically-detect-vulnerabilities)</br>
|
||||
  [5.14. Assign a transaction id to each log statement](#-514-assign-a-transaction-id-to-each-log-statement)</br>
|
||||
  [5.15. Set NODE_ENV=production](#-515-set-node_envproduction)</br>
|
||||
  [5.16. Design automated, atomic and zero-downtime deployments](#-516-design-automated-atomic-and-zero-downtime-deployments)</br>
|
||||
  [5.17. Use an LTS release of Node.js](#-517-use-an-lts-release-of-nodejs)</br>
|
||||
  [5.18. Don't route logs within the app](#-518-dont-route-logs-within-the-app)</br>
|
||||
  [5.19. Install your packages with npm ci](#-519-install-your-packages-with-npm-ci)</br>
|
||||
|
||||
</details>
|
||||
|
||||
@ -156,31 +156,31 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#6-security-best-practices">6. Security Practices (25)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-61-embrace-linter-security-rules">6.1. Embrace linter security rules</a></br>
|
||||
  <a href="#-62-limit-concurrent-requests-using-a-middleware">6.2. Limit concurrent requests using a middleware</a></br>
|
||||
  <a href="#-63-extract-secrets-from-config-files-or-use-packages-to-encrypt-them">6.3 Extract secrets from config files or use packages to encrypt them</a></br>
|
||||
  <a href="#-64-prevent-query-injection-vulnerabilities-with-ormodm-libraries">6.4. Prevent query injection vulnerabilities with ORM/ODM libraries</a></br>
|
||||
  <a href="#-65-collection-of-generic-security-best-practices">6.5. Collection of generic security best practices</a></br>
|
||||
  <a href="#-66-adjust-the-http-response-headers-for-enhanced-security">6.6. Adjust the HTTP response headers for enhanced security</a></br>
|
||||
  <a href="#-67-constantly-and-automatically-inspect-for-vulnerable-dependencies">6.7. Constantly and automatically inspect for vulnerable dependencies</a></br>
|
||||
  <a href="#-68-protect-users-passwordssecrets-using-bcrypt-or-scrypt">6.8. Protect Users' Passwords/Secrets using bcrypt or scrypt</a></br>
|
||||
  <a href="#-69-escape-html-js-and-css-output">6.9. Escape HTML, JS and CSS output</a></br>
|
||||
  <a href="#-610-validate-incoming-json-schemas">6.10. Validate incoming JSON schemas</a></br>
|
||||
  <a href="#-611-support-blocklisting-jwts">6.11. Support blocklisting JWTs</a></br>
|
||||
  <a href="#-612-prevent-brute-force-attacks-against-authorization">6.12. Prevent brute-force attacks against authorization</a></br>
|
||||
  <a href="#-613-run-nodejs-as-non-root-user">6.13. Run Node.js as non-root user</a></br>
|
||||
  <a href="#-614-limit-payload-size-using-a-reverse-proxy-or-a-middleware">6.14. Limit payload size using a reverse-proxy or a middleware</a></br>
|
||||
  <a href="#-615-avoid-javascript-eval-statements">6.15. Avoid JavaScript eval statements</a></br>
|
||||
  <a href="#-616-prevent-evil-regex-from-overloading-your-single-thread-execution">6.16. Prevent evil RegEx from overloading your single thread execution</a></br>
|
||||
  <a href="#-617-avoid-module-loading-using-a-variable">6.17. Avoid module loading using a variable</a></br>
|
||||
  <a href="#-618-run-unsafe-code-in-a-sandbox">6.18. Run unsafe code in a sandbox</a></br>
|
||||
  <a href="#-619-take-extra-care-when-working-with-child-processes">6.19. Take extra care when working with child processes</a></br>
|
||||
  <a href="#-620-hide-error-details-from-clients">6.20. Hide error details from clients</a></br>
|
||||
  <a href="#-621-configure-2fa-for-npm-or-yarn">6.21. Configure 2FA for npm or Yarn</a></br>
|
||||
  <a href="#-622-modify-session-middleware-settings">6.22. Modify session middleware settings</a></br>
|
||||
  <a href="#-623-avoid-dos-attacks-by-explicitly-setting-when-a-process-should-crash">6.23. Avoid DOS attacks by explicitly setting when a process should crash</a></br>
|
||||
  <a href="#-624-prevent-unsafe-redirects">6.24. Prevent unsafe redirects</a></br>
|
||||
  <a href="#-625-avoid-publishing-secrets-to-the-npm-registry">6.25. Avoid publishing secrets to the npm registry</a></br>
|
||||
  [6.1. Embrace linter security rules](#-61-embrace-linter-security-rules)</br>
|
||||
  [6.2. Limit concurrent requests using a middleware](#-62-limit-concurrent-requests-using-a-middleware)</br>
|
||||
  [6.3 Extract secrets from config files or use packages to encrypt them](#-63-extract-secrets-from-config-files-or-use-packages-to-encrypt-them)</br>
|
||||
  [6.4. Prevent query injection vulnerabilities with ORM/ODM libraries](#-64-prevent-query-injection-vulnerabilities-with-ormodm-libraries)</br>
|
||||
  [6.5. Collection of generic security best practices](#-65-collection-of-generic-security-best-practices)</br>
|
||||
  [6.6. Adjust the HTTP response headers for enhanced security](#-66-adjust-the-http-response-headers-for-enhanced-security)</br>
|
||||
  [6.7. Constantly and automatically inspect for vulnerable dependencies](#-67-constantly-and-automatically-inspect-for-vulnerable-dependencies)</br>
|
||||
  [6.8. Protect Users' Passwords/Secrets using bcrypt or scrypt](#-68-protect-users-passwordssecrets-using-bcrypt-or-scrypt)</br>
|
||||
  [6.9. Escape HTML, JS and CSS output](#-69-escape-html-js-and-css-output)</br>
|
||||
  [6.10. Validate incoming JSON schemas](#-610-validate-incoming-json-schemas)</br>
|
||||
  [6.11. Support blocklisting JWTs](#-611-support-blocklisting-jwts)</br>
|
||||
  [6.12. Prevent brute-force attacks against authorization](#-612-prevent-brute-force-attacks-against-authorization)</br>
|
||||
  [6.13. Run Node.js as non-root user](#-613-run-nodejs-as-non-root-user)</br>
|
||||
  [6.14. Limit payload size using a reverse-proxy or a middleware](#-614-limit-payload-size-using-a-reverse-proxy-or-a-middleware)</br>
|
||||
  [6.15. Avoid JavaScript eval statements](#-615-avoid-javascript-eval-statements)</br>
|
||||
  [6.16. Prevent evil RegEx from overloading your single thread execution](#-616-prevent-evil-regex-from-overloading-your-single-thread-execution)</br>
|
||||
  [6.17. Avoid module loading using a variable](#-617-avoid-module-loading-using-a-variable)</br>
|
||||
  [6.18. Run unsafe code in a sandbox](#-618-run-unsafe-code-in-a-sandbox)</br>
|
||||
  [6.19. Take extra care when working with child processes](#-619-take-extra-care-when-working-with-child-processes)</br>
|
||||
  [6.20. Hide error details from clients](#-620-hide-error-details-from-clients)</br>
|
||||
  [6.21. Configure 2FA for npm or Yarn](#-621-configure-2fa-for-npm-or-yarn)</br>
|
||||
  [6.22. Modify session middleware settings](#-622-modify-session-middleware-settings)</br>
|
||||
  [6.23. Avoid DOS attacks by explicitly setting when a process should crash](#-623-avoid-dos-attacks-by-explicitly-setting-when-a-process-should-crash)</br>
|
||||
  [6.24. Prevent unsafe redirects](#-624-prevent-unsafe-redirects)</br>
|
||||
  [6.25. Avoid publishing secrets to the npm registry](#-625-avoid-publishing-secrets-to-the-npm-registry)</br>
|
||||
|
||||
</details>
|
||||
|
||||
@ -189,8 +189,8 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#7-draft-performance-best-practices">7. Performance Practices (2) (Work In Progress️ ✍️)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-71-dont-block-the-event-loop">7.1. Don't block the event loop</a></br>
|
||||
  <a href="#-72-prefer-native-js-methods-over-user-land-utils-like-lodash">7.2. Prefer native JS methods over user-land utils like Lodash</a></br>
|
||||
  [7.1. Don't block the event loop](#-71-dont-block-the-event-loop)</br>
|
||||
  [7.2. Prefer native JS methods over user-land utils like Lodash](#-72-prefer-native-js-methods-over-user-land-utils-like-lodash)</br>
|
||||
|
||||
</details>
|
||||
|
||||
@ -199,21 +199,22 @@ Read in a different language: [**CN**](./README.chin
|
||||
<a href="#8-docker-best-practices">8. Docker Practices (15)</a>
|
||||
</summary>
|
||||
|
||||
  <a href="#-81-use-multi-stage-builds-for-leaner-and-more-secure-docker-images">8.1 Use multi-stage builds for leaner and more secure Docker images</a></br>
|
||||
  <a href="#-82-bootstrap-using-node-command-avoid-npm-start">8.2. Bootstrap using node command, avoid npm start</a></br>
|
||||
  <a href="#-83-let-the-docker-runtime-handle-replication-and-uptime">8.3. Let the Docker runtime handle replication and uptime</a></br>
|
||||
  <a href="#-84-use-dockerignore-to-prevent-leaking-secrets">8.4. Use .dockerignore to prevent leaking secrets</a></br>
|
||||
  <a href="#-85-clean-up-dependencies-before-production">8.5. Clean-up dependencies before production</a></br>
|
||||
  <a href="#-86-shutdown-smartly-and-gracefully">8.6. Shutdown smartly and gracefully</a></br>
|
||||
  <a href="#-87-set-memory-limits-using-both-docker-and-v8">8.7. Set memory limits using both Docker and v8</a></br>
|
||||
  <a href="#-88-plan-for-efficient-caching">8.8. Plan for efficient caching</a></br>
|
||||
  <a href="#-89-use-explicit-image-reference-avoid-latest-tag">8.9. Use explicit image reference, avoid latest tag</a></br>
|
||||
  <a href="#-810-prefer-smaller-docker-base-images">8.10. Prefer smaller Docker base images</a></br>
|
||||
  <a href="#-811-clean-out-build-time-secrets-avoid-secrets-in-args">8.11. Clean-out build-time secrets, avoid secrets in args</a></br>
|
||||
  <a href="#-812-scan-images-for-multi-layers-of-vulnerabilities">8.12. Scan images for multi layers of vulnerabilities</a></br>
|
||||
  <a href="#-813-clean-node_module-cache">8.13 Clean NODE_MODULE cache</a></br>
|
||||
  <a href="#-814-generic-docker-practices">8.14. Generic Docker practices</a></br>
|
||||
  <a href="#-815-lint-your-dockerfile">8.15. Lint your Dockerfile</a></br>
|
||||
  [8.1 Use multi-stage builds for leaner and more secure Docker images](#-81-use-multi-stage-builds-for-leaner-and-more-secure-docker-images)</br>
|
||||
  [8.2. Bootstrap using node command, avoid npm start](#-82-bootstrap-using-node-command-avoid-npm-start)</br>
|
||||
  [8.3. Let the Docker runtime handle replication and uptime](#-83-let-the-docker-runtime-handle-replication-and-uptime)</br>
|
||||
  [8.4. Use .dockerignore to prevent leaking secrets](#-84-use-dockerignore-to-prevent-leaking-secrets)</br>
|
||||
  [8.5. Clean-up dependencies before production](#-85-clean-up-dependencies-before-production)</br>
|
||||
  [8.6. Shutdown smartly and gracefully](#-86-shutdown-smartly-and-gracefully)</br>
|
||||
  [8.7. Set memory limits using both Docker and v8](#-87-set-memory-limits-using-both-docker-and-v8)</br>
|
||||
  [8.8. Plan for efficient caching](#-88-plan-for-efficient-caching)</br>
|
||||
  [8.9. Use explicit image reference, avoid latest tag](#-89-use-explicit-image-reference-avoid-latest-tag)</br>
|
||||
  [8.10. Prefer smaller Docker base images](#-810-prefer-smaller-docker-base-images)</br>
|
||||
  [8.11. Clean-out build-time secrets, avoid secrets in args](#-811-clean-out-build-time-secrets-avoid-secrets-in-args)</br>
|
||||
  [8.12. Scan images for multi layers of vulnerabilities](#-812-scan-images-for-multi-layers-of-vulnerabilities)</br>
|
||||
  [8.13 Clean NODE_MODULE cache](#-813-clean-node_module-cache)</br>
|
||||
  [8.14. Generic Docker practices](#-814-generic-docker-practices)</br>
|
||||
  [8.15. Lint your Dockerfile](#-815-lint-your-dockerfile)</br>
|
||||
|
||||
</details>
|
||||
|
||||
<br/><br/>
|
||||
@ -433,8 +434,7 @@ function someFunction() {
|
||||
}
|
||||
|
||||
// Avoid
|
||||
function someFunction()
|
||||
{
|
||||
function someFunction() {
|
||||
// code block
|
||||
}
|
||||
```
|
||||
@ -1520,14 +1520,14 @@ Thank you to all our collaborators! 🙏
|
||||
Our collaborators are members who are contributing to the repository on a regular basis, through suggesting new best practices, triaging issues, reviewing pull requests and more. If you are interested in helping us guide thousands of people to craft better Node.js applications, please read our [contributor guidelines](./.operations/CONTRIBUTING.md) 🎉
|
||||
|
||||
| <a href="https://github.com/idori" target="_blank"><img src="assets/images/members/ido.png" width="75" height="75"/></a> | <a href="https://github.com/TheHollidayInn" target="_blank"><img src="assets/images/members/keith.png" width="75" height="75"/></a> | <a href="https://github.com/rluvaton" target="_blank"><img src="assets/images/members/raz-luvaton.jpg" width="75" height="75" alt="Raz Luvaton" loading="lazy"/></a> | <a href="https://github.com/josh-hemphill" target="_blank"><img src="assets/images/members/jhemphill.jpg" width="75" height="75" alt="Josh Hemphill" loading="lazy"/></a> |
|
||||
| :--: | :--: | :--: | :--: |
|
||||
| [Ido Richter (Founder)](https://github.com/idori) | [Keith Holliday](https://github.com/TheHollidayInn) | [Raz Luvaton](https://github.com/rluvaton) | [Josh Hemphill](https://github.com/josh-hemphill) |
|
||||
| :----------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
||||
| [Ido Richter (Founder)](https://github.com/idori) | [Keith Holliday](https://github.com/TheHollidayInn) | [Raz Luvaton](https://github.com/rluvaton) | [Josh Hemphill](https://github.com/josh-hemphill) |
|
||||
|
||||
### Collaborator Emeriti
|
||||
|
||||
| <a href="https://github.com/refack" target="_blank"><img src="assets/images/members/refael.png" width="50" height="50"/></a> |
|
||||
| :-------------------------------------------------------------------------------------------------------------------------: |
|
||||
| [Refael Ackermann](https://github.com/refack) |
|
||||
| :--------------------------------------------------------------------------------------------------------------------------: |
|
||||
| [Refael Ackermann](https://github.com/refack) |
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user