Eddie Eddie - 3 years ago 164
Node.js Question

I could use a little guidance on larger Node applications

I am a C# .NET developer (15 years) and NodeJS developer (3 spotty /part-time years in small applications but falling in love). I am just getting into my first larger node project and am wondering if I am on the right track with regards to design patterns before I commit. Most of the examples we see on the web regarding node put much content into one file, this is done so we can easily follow a tutorial or example.

Right now, I have a desire to create my node application with many files, single responsibility, I am thinking as follows (the project is much different but this is an example most can understand):

/server.js // (requires /usermanager/index.js)
/usermanager/index.js //(requires all other files for user management)
/usermanager/createuser.js
/usermanager/changepassword.js
/usermanager/validateemail.js


This is what the coder in me wants to do, but I am wondering if this is best practice before I commit to this.

Yes / No?

If you can point me to some great documentation on node design patterns that covers large projects structure, that would also be awesome!

Any GitHub repos that may show such a larger project.

Many thanks for your time.

Answer Source

I came from the same background as you (.NET). After using JavaScript my team and I figure out that using JavaScript for big code projetcs its Impossible... So se decided to use Typescript!

I have created a project that have some success in the community https://github.com/dwyl/hapi-typescript-example

With this structure (feature base) and types its much easier to scale your code!

Let me know it you have any questions!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download