Cloud9 Node js Express jade IDE: file structure

239 views Asked by At

In Cloud9 Express IDE example I see in folder/file routes/users.js - please tell me why this is in separate file -what is the intention of users.js as a distinct file? :

/*

    GET users listing.
    */

exports.list = function(req, res){
res.send("respond with a resource");
}; 
1

There are 1 answers

0
user5001293 On

ok Im trying to answer that one myself (feel free to chime in): The basic Express set up folder structure according to Expressjs.com looks like this:

├── app.js

├── bin

│ └── www

├── package.json

├── public

│ ├── images

│ ├── javascripts

│ └── stylesheets

│ └── style.css

├── routes

│ ├── index.js

│ └── users.js

└── views

├── error.jade

├── index.jade

└── layout.jade

It is suggested and not obligatory. However for noobs like me this helpful website says:

If you are getting started with Express it is recommended that you use the structure from the generator.

Edited: In the particular folder structure generated in Cloud9 Express the file /routes/users IS intrinsic to a typical Express-Jade setup. Basic routing tutorial here answers what each of these files is doing