lovasoa / SQLpage

Fast SQL-only data application builder. Automatically build a UI on top of SQL queries.
https://sql.datapage.app
MIT License
1.53k stars 85 forks source link

Path parameters #559

Open maekoos opened 3 weeks ago

maekoos commented 3 weeks ago

What are you building with SQLPage ?

I am building a simple accounting platform.

What is your problem ? A description of the problem, not the solution you are proposing.

I'd like to have routes that go /app/:serviceId/, /app/:serviceId/ledger, /app/:serviceId/ledger/:accountId/info.

What are you currently doing ? Since your solution is not implemented in SQLPage currently, what are you doing instead ? I am using query parameters, but it is quickly becoming a bit messy.

Describe the solution you'd like

There are already a tonne of filesystem routers to take inspiration from, for example:

Most of them use folders and files with [paramter-name] to add route parameters.

Describe alternatives you've considered

As mentioned, search parameters work but become a bit ugly after a while, especially since it is not possible to use relative urls to simplify links.

Route parameters would also allow someone to build a (almost) proper REST-api which would be kind of cool.

maekoos commented 3 weeks ago

I have also considered using a proxy server - but that feels just way too complex for such a simple feature.

When looking at how files are resolved however, I see how this could be somewhat problematic. We'd probably need to either generate a "router" from the file system on startup/file change, or resolve request paths one / at a time...

lovasoa commented 3 weeks ago

Hello and welcome to SQLPage!

This feature has recently been implemented in https://github.com/lovasoa/SQLpage/pull/544 see https://sql.datapage.app/your-first-sql-website/custom_urls.sql

It will be in the next stable version!

maekoos commented 3 weeks ago

Ahha! Nice - I'll give it a try, although my first impression is that it feels a bit cumbersome....