I’m writing a larger App with duplex communication and database access via Node.js (with socket.io and mysql modules).
Therefore I want to source out some files, so i don’t have a huge server.js File (for example: a file for chat stuff, a file for database connection stuff, etc).
Is there a good method to arrange these files in my project? I am looking for something like getScript from jQuery, but I assume this won’t worke, because it is an Ajax call, which doesn’t make a lot sense on a Websocket-server, right?
Or is the best way to create own Modules!?
Yes create modules.
And if you want to pass values to a module you can make a function like:
This is the modular approach my favorite. Then you call like this from your code.
Then you have the more traditional OOP
Then you call like this from your code.