Open Zurdge opened 2 months ago
Thank you for the contribution @Zurdge, great idea. I am very curious on whether or not this is something where there is a significant need for.
Maybe a modular approach which lets more space for custom routing strategies makes sense so people can come up with individual file naming conventions. Following a strategy pattern or similar, a significant refactor may be required.
I am imagining an API like:
import { DirectoryStrategy, FlatStrategy } from "express-file-routing"
createRouter(app, {
strategy: new DirectoryStrategy() // this might be the default directory-file-based strategy like Next.js
}
Therefore, an strategy interface for generating the routes needs to be defined. What do you think?
Yeh I think this is a good idea! When I next get time, I'll try and scope out what this enhancement might look like and reply in this thread. 👍
I would like to structure my API routes in a flat directory, similar to how Remix handles it's routing. https://remix.run/docs/en/main/discussion/routes#conventional-route-configuration
Would it be ok to implement something similar to this? I've tested for my own needs and it works well. Happy to make adjustments 👍