This is a very broad question…
I don’t see anything wrong with having the middleware file in the Fractal folder. Example in the example above, the loginMiddleware.js can safely goto login/ directory.
When I need to applyMiddleware, I can simply import the file.
That being said, if every action/ component has a middleware attached to it, then Fractal might be confusing, and I’d simply extract them into their own folder.
I’ve personally never came across a use case with more than 4 custom middlewares. Will be happy to help if you can share more details about your problem.