Express: How to require a file in node js express and pass a parameter value to it?
问题 This question has a big relation with How to require a file in node.js and pass an argument in the request method, but not to the module? -- Question. I have a node js Express app. when visitor visits http://localhost/getPosts , the main node js file requires ./routes/posts file and sends a database connection to the required file. app.use('/getPosts', require('./routes/posts')(myDatabase)); the content of ./routes/posts file is given below: var express = require('express'); var router =