I am using adminJS and want to log all incoming requests along with the adminUser that initiated those requests.I added a simple middleware but it does not get executed at all
import AdminBro from 'adminjs';
import AdminBroExpress from '@adminjs/express';
const adminBro = new AdminBro({...});
const adminbroRouter = AdminBroExpress.buildAuthenticatedRouter(
adminBro,
{
authenticate: async (email, password) => {
try {
const account = await AuthService.getByEmail(email);
if (!account) {
return false;
}
const { password: accountPassword } =
await AuthService.getPasswordByEmail(email);
if (!(await isHashEqual(accountPassword, password))) {
return false;
}
if (!AuthService.isAdmin(account as any)) {
return false;
}
return account;
} catch (error) {
return false;
}
},
cookiePassword: ADMINJS_COOKIE_PASSWORD,
cookieName: ADMINJS_COOKIE_NAME,
maxRetries: {
count: ADMINJS_MAX_RETRIES_COUNT,
duration: ADMINJS_MAX_RETRIES_DURATION,
},
},
null,
sessionOptions,
);
adminbroRouter.use((req, res, next) => {
// Why is this not getting called?
console.log(req.path, req.adminUser);
return next();
});
Adminjs version 6.2.4 if that helps
UPDATE 1
Updated adminjs to 6.7.4 which is the latest version and ran the code here, still the same problem