I am trying to create a seperate file that will hold all the modules that I'm using in the project. But it is giving me app.use is not a function error.
I'v been spending alot of time on this. So, I just wanted to know if this is even possible.
Code that I have tried so far.
index.js
const requireModules = require("./require");
for (let keys in requireModules) {
app.use(keys);
}
Require.js
const cors = require("cors");
const morgan = require("morgan");
const helmet = require("helmet");
module.exports = {
cors: cors(),
morgan: morgan("common"),
helmet: helmet(),
};