Reputation: 25
Wondering what is the best way to structure the ejs part of the application, here is my current structure.
inside maindir/
inside the maindir/homepage/
inside the /maindir/homepage/ejs/
is this a decent way to structure an application? specifically the importing from the partials/ directory into each new view or is there a better way to achieve this goal ?
Upvotes: 0
Views: 3538
Reputation: 1748
Using express-generator can be a good starting point if you are new to setting up an express
app.
Upvotes: 0
Reputation: 23060
is this a decent way to structure an application?
The question/answer is entirely subjective.
My answer will be based on what most developers do.
Traditionally, the root folder structure of an Express application is the following:
example
├── app.js
├── controllers
├── models
├── public
└── views
As you can see this is the MVC pattern. An alternative pattern to the above, which is common in frontend applications, is organizing it by feature/components:
example
├── app.js
├── auth
│ ├── auth-controller.js
│ ├── auth-view.ejs
│ └── auth-model.js
├── notification
│ ├── notification-controller.js
│ ├── notification-view.ejs
│ └── notification-model.js
└── topic
It boils to your personal preference or what your team decides.
Upvotes: 1