bunrest icon indicating copy to clipboard operation
bunrest copied to clipboard

Middlewares Activating for All Methods of a Route

Open lewisjr opened this issue 8 months ago • 3 comments

I have a path that can be accessed via GET or POST, for differing reasons. I have an auth middleware on the GET handler, however, the middleware is also being applied to the POST handler. See the code below:

authRouter.post("", async (req, res) => {
   // stuff
   res.status(200).json({ data });
});

authRouter.get("", authMiddleware, async (req, res) => {
   // stuff
   res.status(200).json({ data });
});

app.use("/analytics", authRouter);

Other Relevant Info:
Bun version: v1.0.7
bunrest version: v1.3.6
platform: ubuntu 20.04 (docker image)
node installed: yes
node version: v18.18.2

lewisjr avatar Oct 27 '23 23:10 lewisjr