0

I'm coming to NodeJS from other platforms and so far everything makes total sense. I'm starting to look at the different ways to structure applications/site, with the aim to get a sense of whats out there.

The one I'm currently stuck on is when you want to have different functionality in your app/site split into different packages (not simply different modules) - a similar approach which has been taken by Atom and mentioned briefly here.

I get that you can split the functionality into distinct packages and that usually these packages are small, but I'm missing the piece on how to glue it all together and trigger them to "execute". Are the any samples on this, reference implementation, guidance, etc?

Community
  • 1
  • 1
vdh_ant
  • 12,720
  • 13
  • 66
  • 86
  • What is the difference here between a module and a package in your parlance? Is the package a superset of modules or something else? You can require('') your own code the same way you can a node module. Maybe I am missing something in your question. – barry-johnson Mar 02 '14 at 04:27
  • you simply expose functions which depend to an instance of your appl to be able to execute their behavior. Its not complicated you simply write a smaller package if that its required , then you start invoking your app code you glue somewhere your module. Try to look at middlewares which require an instance of an app to be able to run, how you will call it. Although this approach is usually preferred, having like 50 nodejs modules for your app doesn't make it a better app, you could package the entire modules into an extensions folder and load according to app config.There many ways to do this. – Gntem Mar 02 '14 at 09:57
  • Sorry for the confusion, when I say package, I mean something that I can package as a private NPM package and add as a dependency to the main app. But I'm hoping to get to the point where I don't need to change code in the main app besides the package dependencies - or at least thats the architecture I have in my head. – vdh_ant Mar 02 '14 at 13:16

0 Answers0