When building out new endpoints, I like to prefix them with /v1 just to ensure I can version them in the future if needed.
As a result, a new project might fetch data from /v1/posts, /v1/messages, etc… Sometimes you’ll also end up with longer paths, like /v1/admin/users, /v1/admin/subscriptions, etc…
In order to support this grouping I have created a single Netlify Function just called “v1”. It receives all requests that start with v1 and then directs them to the appropriate handler. In terms of code organization I’m a fan of this approach. Its clear to me how a request gets to the appropriate handler and I can even do some verification at the parent level which is nice.
My concern here is that by wrapping up all of my API end points in to a single Netlify Function I’m incurring a performance hit or that as the size of my end points grow I’ll hit some sort of cap and need to refactor.
Just wanted to get some thoughts on this before going too far with this approach.