Alaric James Hartsock
Alaric James Hartsock

Reputation: 375

What's the purpose of the express.js boilerplate code?

I'm new to Node and Express. And I was just wondering what the significance/use of most of the boilerplate directories that are automatically created when you create an express project.

I've looked online to try to explain the significance of these files and such, and I was just looking for a concise answer and maybe something that somebody who was in my position can look at. The official API doesn't explain the directories, just acknowledges them and shows you how to create them.

bin
     www.js
node.modules
     ...
public
     images
     javascripts
     stylesheets
          style.css
routes
     index.js
     users.js
views
     error.jade
     index.jade
     layout.jade
.gitattributes
app.js
package-lock.json
package.json

I don't have any questions about node.modules, public, views, .gitattributes, package-lock.json, or package.json. Just wondering what the significance and relation to the rest of the project www.js, index.js, users.js, and app.js are. I know that app.is the "main" entry point for the project, but what is www.js supposed to do? What is users.js and index.js supposed to do? I want to be sure that I'm using these files as intended and as expected by other developers. I appreciate your time.

Upvotes: 2

Views: 367

Answers (1)

Noob
Noob

Reputation: 2807

Express provides this structure in order to encourage developers to structure the code in a good way that can be easily managed and maintained.

Mozilla express tutorial will answer all your questions mentioned above. It's easy to follow and explains everything regarding the code structure and good code practices.

Here is github of that tutorial were you can check out how everything is impelemented.

Here is a good SO explanation regarding bin/www .

Upvotes: 3

Related Questions