1
I am new to using Express JS and would like to make a direction according to the session created, IE, according to the user profile, the application has an initial route "audit" and will have 2 user profiles and I want the express to call the route file corresponding to the profile, basically would be more or less like this:
var routerAdmin_1 = require('./routes/admin_1');
var routerAdmin_2 = require('./routes/admin_2');
app.use('/auditoria', (req, res, next) => {
if(req.session.cargo == 'ADMIN_1'){
chamar routerAdmin_1
}else if(req.session.cargo == 'ADMIN_2'){
chamar routerAdmin_2
}else{
console.log('Acesso negado')
}
});