Express: How to pass app-instance to routes from a different file?

后端 未结 8 1068
误落风尘
误落风尘 2020-11-29 16:34

I want to split up my routes into different files, where one file contains all routes and the other one the corresponding actions. I currently have a solution to achieve thi

8条回答
  •  我在风中等你
    2020-11-29 16:53

    Use req.app, req.app.get('somekey')

    The application variable created by calling express() is set on the request and response objects.

    See: https://github.com/visionmedia/express/blob/76147c78a15904d4e4e469095a29d1bec9775ab6/lib/express.js#L34-L35

提交回复
热议问题