Answer the question
In order to leave comments, you need to log in
How to create the structure of a Node.JS application?
Hello.
Task: to write a site (chat) on node.js + socket.io, mongodb and angularjs.
What will work and how?
- node will only be used to return index.html and process ajax requests
- nginx will return all statics to the node server
- angular will navigate through pages and load data from node via ajax
- registration and authorization
- saving and sending messages
- creating chats
- loading chats
- and many small functions that will work with mongodb through node
- chats
- users
- messages
- other..
..
code - processing ajax post requests, the rest is a trifle (connecting modules and starting the server)
Answer the question
In order to leave comments, you need to log in
It is better to wrap models in abstraction, moreover, take out the general code separately, the code for the browser - separately, the code for the node - separately. To make `require(['fs'], (fs) => fs.read)`, for example, work the same in the browser and in the node.
Do not do it in one file - scatter it among plugins, look / try the architect and pym packages, or use your own interface. It is even better to use some kind of cluster and do all the functionality of the application in one thread. Many small ones are better than one big one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question