I\'m doing a project in Node.js using express. Here\'s my directory structure:
root
|-start.js
|-server.js
|-lib/
| api/
| user_getDetails.js
|
app.js
var c_file = 'html.js';
var controller = require(c_file);
var method = 'index';
if(typeof controller[method] === 'function')
controller[method]();
html.js
module.exports =
{
index: function()
{
console.log('index method');
},
close: function()
{
console.log('close method');
}
};
dynamizing this code a little bit you can do magic things :D