Basic structure of a NodeJS application

Take into account that in order to function a NodeJS application must respect the following basic structure:

 |_____ app.js
 |_____ public
 |_____ tmp

That is, your application must contain at least one app.js file, which will be the gateway to your application. In that file you must define at least one «request handler».

In addition, your application should contain a directory called public, which will be the root of your website and where you will place the static files of your application (images, CSS, JS, …). If your NodeJS is not a web application, it is only an app that receives and returns data, the public folder is not necessary.

Finally, you need a directory called tmp, which will allow you to force a reboot of your NodeJS application. To do this you should run the following command from the command line:

<br />
touch tmp/restart.txt<br />