DEV Community

Cover image for Node.js best practices
Tomek Poniatowicz for GraphQL Editor

Posted on • Updated on • Originally published at blog.graphqleditor.com

Node.js best practices

Node.js is the most popular choice when building the backend for your app, no matter if you prefer a traditional REST API or using it to build something modern like the GraphQL server.

Node.js

Node.js is a JavaScript runtime using an event-driven I/O model which makes it extremely efficient when it comes to making scalable network applications. It's cross-platform, so whether you are building a mobile app, web app or IoT, Node will do the job. It's light, it's scalable & it delivers! Whether you are building a side project or working on an enterprise app Node.js will fit your needs.

NodeJS work with any technology

Source: undraw.co

Best practices

Node.js offers a lot, but to bring to the best you need to know and follow its best practices. If you are wondering where to find them the awesome open-source community is here to help!

This repo is the largest compilation of best Node.js content available online. It contains:

  • more than 80 best practices,
  • useful style guides
  • architectural patterns

As it's maintained by the community the "Node.JS Best Practices" is growing rapidly and new pull requests with fresh Node.js content are being created on a daily basis.

GitHub logo goldbergyoni / nodebestpractices

โœ… The Node.js best practices list (July 2023)

Node.js Best Practices

Node.js Best Practices


102 items Last update: July 19, 2023 Updated for Node 19.0.0

Follow us on Twitter! @nodepractices


Read in a different language: CNCN, FRFR, BRBR, RURU, PLPL, JAJA, EUEU (ESES, HEHE, KRKR and TRTR in progress! )


๐ŸŽŠ 2023 edition is here!

  • ๐Ÿ›ฐ Modernized to 2023: Tons of text edits, new recommended libraries, and some new best practices

  • โœจ Easily focus on new content: Already visited before? Search for #new or #updated tags for new content only

  • ๐Ÿ”– Curious to see examples? We have a starter: Visit Practica.js, our application example and boilerplate (beta) to see some practices in action

Welcome! 3 Things You Ought To Know First

1. You are reading dozens of the best Node.js articles - this repository is a summary and curation of the top-ranked content on Node.js best practices, as well as content written here by collaborators

2. It is theโ€ฆ

Best practices are divided into 7 groups of which each of them contains numerous good practices gathered from the community:

  1. Project structure
  2. Error handling
  3. Code style
  4. Testing & Quality
  5. Going to production
  6. Security
  7. Performance

Each good practice contains a TL;DR summary as well well as a link to extended content including:

  • detailed information
  • code examples
  • important quotes from different sources

Awesome, right? Rember to show the repo maintainers some love and leave them a star or contribute if you have some useful Node.js tips!


Boost your API with GraphQL

GraphQL Editor is a tool that would help you build, manage & deploy your GraphQL API much faster thanks to dozens of built-in micro features like mock backend or frontend engine for previewing your GraphQL queries!

GraphQL Editor

Top comments (5)

Collapse
 
raftheunis87 profile image
Raf Theunis

Very interesting repository!

I was looking at the "Handle errors centrally. Not within middlewares" example. I do understand that it's better to handle errors within a dedicated object. But I found the given example to be incomplete? Say for example that I wrote an AppError class that extends from Error. If I throw this AppError in my application, how can I be sure that my dedicated error object will handle this?

Maybe a complete code example/gist could make this clearer for me.

Anyway, very nice repository! Keep up the great work!

Collapse
 
nasidulislam profile image
Nasidul Islam

Great collection of tips !!

Collapse
 
jagpalkooner profile image
JagpalKooner

Hey guys to learn HTML CSS JS API we have frontendmentor.io for projects to complete is there another similar website to learn react and do sample projects?

Collapse
 
jonathanbrizio profile image
Jonathan Brizio

Until the moment, always work with SQL & NoSQL Databases, but when moving to GraphQL, I will take a look at your editor. Thanks for share!

Collapse
 
bravemaster619 profile image
bravemaster619

GraphQL is NOT a different type of database. It's more like a new idea of API structure, often compared to REST API.