The perfect architecture flow for your next Node.js project

Brian Neville-O'Neill on October 15, 2019

Written by Piero Borrelli✏️ A good start is half the battle, said someone wiser than me. And I can’t think of any quote that would better describe... [Read Full]
markdown guide

"Use promises" is a bit 2015 kind of advice. Async / await is widely adopted and it is a step ahead of Promises.


That's like saying you won't be using promises with async/await.

It's just a different way of consuming them.


Exactly, I use promises exactly to get my async function to await for a second function to finish. They are different things


+1 for Rule #8: Use another layer for third-party services calls

I worked at 3 startups all involved with online payment, all switched from one payment processor (Stripe, Adyen, and whatnot) to another for a better rate or more features, mostly for a better rate. After going through the painful refactoring for the first 2, I realised I should've written a wrapper around whatever payment processor npm/API I would use


Yes but you have to create a unified API. Thankfully this should be easier for payment processors than for writing a unified DB access layer that would allow switching from MySQL to MongoDB.


Rule #6 has some buggy code. database is specified for the arrow function param but db is being called


You noticed too? Well, we all get the gist tho 😉


Good writing, but I'd not use express for any kind of project.

If you want a real stack use something like Adonis or Nest which have been built to create application/api at scale.


Do you have some project as boilerplate where I can follow these valuable rules?

If yes,do you mind to share it?

Thanks for your post!


I really liked the functional approach of the dependency injection


Wonder if you have more examples on how to execute the piece of code about DI from a caller perspective. Thanks, great post.


Your article is interesting for beginners. CLI provided by frameworks (Vuejs, Angular, express) are generating scaffolds to learn from! It's a good starting point to follow.


I'm always amazed at how under-architected most node code is.

code of conduct - report abuse