-
-
Notifications
You must be signed in to change notification settings - Fork 40
🚀 Formats #502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 Formats #502
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
I like format c the most (PAGES.site_id({ id: 7 }) tbh |
|
Out of all formats, option B feels the most intuitive to me ( |
| const ACTIONS = { | ||
| "default /contract/[id]": (params: { id: (string | number), lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => { | ||
| return `${params?.lang ? `/${params?.lang}`: ''}/contract/${params.id}` | ||
| }, | ||
| "create /site": (params?: { lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => { | ||
| return `${params?.lang ? `/${params?.lang}`: ''}/site?/create` | ||
| }, | ||
| "update /site/[id]": (params: { id: (string | number), lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => { | ||
| return `${params?.lang ? `/${params?.lang}`: ''}/site/${params.id}?/update` | ||
| }, | ||
| "delete /site/[id]": (params: { id: (string | number), lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => { | ||
| return `${params?.lang ? `/${params?.lang}`: ''}/site/${params.id}?/delete` | ||
| }, | ||
| "noSatisfies /site_contract": (params?: { lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => { | ||
| return `${params?.lang ? `/${params?.lang}`: ''}/site_contract?/noSatisfies` | ||
| }, | ||
| "send /site_contract/[siteId]-[contractId]": (params: { siteId: (string | number), contractId: (string | number), lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => { | ||
| return `${params?.lang ? `/${params?.lang}`: ''}/site_contract/${params.siteId}-${params.contractId}?/send` | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action /the/path, and a default action is named also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could skip the default prefix for convenience?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, with the function route() we can have collision quite fast. (Here with a page for example.
So, maybe I'll have to keep it. I don't really like it.
Or maybe having the default only if collision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the route() function, in its current implementation, would be the single entry point for everything (pages, actions, servers, etc.) right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(OMG, experience of comments on a PR is a disaster, I get things in wrong order... And I'm not even sure I saw everything)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be any benefit of having separate functions (just like we have separate objects, could be page(), action(), etc.) rather than a single route() function?
I can already see 2:
- It'd fix the name collision issue
- It'd also make it clear if you're pointing to a page, an action, etc. and avoid mistakes
Any drawbacks that you can think of?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that collision can happen only* with the default (I could almost rename it action instead of default? )
The highest request I had was to merge everything into one object ROUTES. Then we came into the fonction 'route()' where people wanted everything.
So... I don't know... I think it's already a lot of options 😅
(and I probably want to provide one option when there is only 1 required param to give it without object!) 😳
You are somewhere to chat live? 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that collision can happen only* with the default
Yes
I could almost rename it action instead of default?
Let's keep SvelteKit's semantics and use default
You are somewhere to chat live?
Just sent you a Discord invite 🙂
packages/vite-plugin-kit-routes/src/test/ROUTES_format-route-underscore.ts
Show resolved
Hide resolved
|
let's do a |
It's WIP
Todo
Breaking
methods&actionsare not the first param anymore. They are part of thekeyQuestion A/
I'm not sure about prepending and appending yet... I like
PAGES.update_site_id({ id: 7 }), it's very "self explain".Should prepend / append be an option or I leave it like this?
Optional params are not part of the key anymore
I learned that it cannot do collision (SvelteKit will complain if not)
New format / New default?
Question B/
In format "variable", should we prefix by
PAGES_ / ACTIONS_ / SERVERS_ / LINKS_(like today) orROUTE_orroute_or nothing?Question C/
Should it be options?
I tag you @tmarnet @xKesvaL @hmnd @brandonp-ais as you tried and reported already something 🎉
If you have a few input, I would be happy to check :)
(code is not working yet.)