Here is the sample.js :
module.exports = (function (param) {
// I'm expecting param to be available here
})();
Here is the app.js
var sampleMsg= require('./controller/sample')(param);
app.use('/sample', sampleMsg);
But the above code when run throws the following error:
D:\Working\GUI\Server\node_modules\express\lib\router\index.js:140
var search = 1 + req.url.indexOf('?');
^
TypeError: Cannot read property 'indexOf' of undefined
at Function.handle (D:\Working\GUI\Server\node_modules\express\lib
\router\index.js:140:27)
at router (D:\Working\GUI\Server\node_modules\express\lib\router\i
ndex.js:46:12)
at Object.<anonymous> (D:\Working\GUI\Server\app.js:267:54)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3