Middleware of root group don't run when exists sub groups with middlewares.
Hello, I have a project with a root group and a subgroup. Both with middlewares. In my root group, I have authentication middleware, it needs to be executed before all routes and put the user object in the request body.
And in my subgroup, I have two more middleware, they need to run after the middleware auth and need to receive the user object from the request, but when I use middleware in both groups, the middleware auth does not work.
Example:
route.options({ middleware: ['auth'] }, () => {
route.group('/organizations', () => {
// Here my auth middleware works and I can get the user from request.
route.get("/", "organization.controller@index");
route.options({ middleware: ["organization", "member", 'auth'] }, () => {
// Here, the auth middleware from root group don't works, and I can't receive the user from request
// To do it, I need to put the auth middleware in last position of middleware array of my sub group to run and get the user from reques
});
});
});
My package.json
{
"name": "acai",
"version": "1.0.0",
"description": "Default boilerplate application for the Açai framework",
"private": true,
"scripts": {
"start": "ts-node-dev --files ./index.ts",
"stub": "ts-node node_modules/@acai/stubber/dist/index.js"
},
"dependencies": {
"@acai/config": "^1.0.0",
"@acai/model": "^0.7.6",
"@acai/query": "^0.5.7",
"@acai/router": "^2.0.4",
"@acai/server": "^1.0.2",
"@acai/stubber": "^0.1.0",
"@acai/utils": "^0.2.5",
"@acai/validator": "^0.3.0",
"aws-sdk": "^2.916.0",
"axios": "^0.21.1",
"change-case-all": "^1.0.14",
"crypto": "^1.0.1",
"luxon": "^1.26.0",
"mariadb": "^2.5.3"
},
"devDependencies": {
"@acai/testing": "^0.1.4",
"@types/luxon": "^1.26.0",
"@types/node": "^14.14.25",
"ts-node-dev": "^1.1.1",
"typescript": "^4.1.4"
}
}