I am creating a meteor package using iron:router, it works great. The routes logic of this package is very specific.
But as soon as I add this package in a Meteor app that is also using iron:router, the hooks defined by the Meteor app (onBeforeAction, onAfterAction, ...) are called for the routes created by the package. I'd like to prevent my package routes to execute the hooks of the app.
Is there a simple piece of code I could use to isolate the routes of my package from the "external" hooks? Maybe I could create a specific RouteController?
The last option for me is to implement a router from scratch...
Thank you!
The code that solved my issue is the following:
let MyRouter = new Iron.Router;
MyRouter.onBeforeAction(Iron.Router.bodyParser.json());
MyRouter.onBeforeAction(Iron.Router.bodyParser.urlencoded({extended: false}));
The solution is to declare a new isolated router. The 2 lines under the router declaration enable to retrieve the data of POST requests.