//backendcontrollersuserController.js
module.export.register= async(req,res)=> {
console.log("register controller");
}
module.export.login= async(req,res)=> {
console.log("Login controller");
}
//backend
outesuserRoutes.js
const { register, login } = require('../controllers/userController')
module.exports = {
method: function() {},
otherMethod: function() {},
};
module.exports = {
method: function () {},
otherMethod: function () {},
};
or just:
module.exports = {
fn_name1,
fn_name2
};
Or just:
exports.method = function() {};
exports.otherMethod = function() {};
Then in the calling script:
const myModule = require('./myModule.js');
const method = myModule.method;
const otherMethod = myModule.otherMethod;
// OR:
const {method, otherMethod} = require('./myModule.js');