Structure of Express/Mongoose app

后端 未结 5 1402
醉酒成梦
醉酒成梦 2021-02-10 09:00

How should I go about structuring my express/mongoose application, so that I can use my schemas, models, routes and the functions that get called when those routes are hit?

5条回答
  •  無奈伤痛
    2021-02-10 09:56

    In your application structure you have mixed the database logic with the express route handling and passing the express application variable to model. I would avoid the mixing these two together, also you could take a look at this structure https://gist.github.com/fwielstra/1025038.

提交回复
热议问题