Sunday, 14 May 2017

Node Express CRUD application folder structure

I am using the following folder structure for my express CRUD application. I use it to have ideal manageable code of each file containing not more than 70 lines of code. What are your thoughts on the folder structure?

- bin\
    - www
- common\
- enums\
    - logTypesEnum.js
- validators\
    - studentNameValidator.js
- config\
    - db.js # config file for database connection
- models\
    - log.js # contains model data for model 'log'
- routes\
    - log\
        - index.js # handles all routes for /log/ endpoints and requires files in the directory and also contains middleware code
        - insert.js # handles all routes for /log/insert endpoints
        - remove # handles all routes for /log/remove endpoints
        - exportCSV.js # handles all routes for /log/exportCSV endpoints
    - student\
        - index.js 
        - insert.js
        - remove.js
- public\
    - javascripts
    - images
    - stylesheets
- views\
    - log\
        - index.jade
        - insert.jade
        - remove.jade
        - exportCSV.jade
    - student\
        - index.jade
        - insert.jade
- app.js



via Kenil Domadia

No comments:

Post a Comment