VeryGoodOpenSource / dart_frog

A fast, minimalistic backend framework for Dart 🎯
https://dartfrog.vgv.dev
MIT License
1.87k stars 150 forks source link

Route Prefixes and Versions #1511

Open alexrabin opened 2 months ago

alexrabin commented 2 months ago

Description

Just wanted to say thank you so much for this package. I love it.

Okay so I was curious if it would be possible to allow the developer to add a global route prefix and possibly specify a version for the route. Like in Nest.js with global prefixes and Versioning.

So for example, i want my api’s to start with “/api/v1/“. Right now I would have to create two folders and then put all my routes in those folders but instead I’d like to be able to specify the global prefix in the custom server endpoint and then within each route I’d like to then specify the version of the route.

Requirements

Additional Context

No response

tomarra commented 1 month ago

Hi @alexrabin 👋 Thanks for opening this issue.

Overall we think that the suggestion is valid but also doesn't fit the main development style we have implemented in Dart Frog. Typically given how file path based frameworks work the solution of creating new folders and copying in (or referencing) files is the typically way to achieve what your looking for. That being said we did have some questions around the use case your trying to solve here. Is it just for versioning in a Production deployment or are there development use cases that could be aided by having this functionality as well?

This could be something that may be solved by our work on a plugin/codegen system to allow others to write plugins that modify the build process for a Dart Frog project as well but we don't have an ETA right now for that landing.

alexrabin commented 1 month ago

This is for production. In the event I need to make different versions of an api, I'd like to.

The codegen route sounds promising.