简体   繁体   中英

Cloud9 Node js Express jade IDE: file structure

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");
}; 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM