uppercase methods — export function GET, etc #5359
Replies: 16 comments 10 replies
-
Yes! Go go go! |
Beta Was this translation helpful? Give feedback.
-
I honestly don't like the aesthetics either but if that's the only minor gripe then the benefits still outweigh the fact that it's a breaking change imho because after all Svelte Kit is still in beta and it would be easy to migrate to the new naming convention. |
Beta Was this translation helpful? Give feedback.
-
Migrating is a simple "Find and Replace", so not devastating. |
Beta Was this translation helpful? Give feedback.
-
Definitely in favour of this even just to get rid of the |
Beta Was this translation helpful? Give feedback.
-
for me upper-case names in JS evoke they are constants in global scope, not really like it from this point of view, but on other hand it looks like more HTTP-ish. Even tho, I would maybe like to use upper-cased name as string: export default {
'GET': ({ params }) => {
return {};
}
} looks interesting, except as you said, that intendation level. Hmm, maybe I would let it be named exports, it also makes more sense for me, as I export only some handlers, not all of them. |
Beta Was this translation helpful? Give feedback.
-
Just my 2 cents here, I really don't like the verbs in uppercase, uppercase in js is for constants |
Beta Was this translation helpful? Give feedback.
-
I think this is a good change for all of the above listed reasons. Many documentation sites use uppercase letters; for example, the Mozilla docs use all uppercase verbs for the method property: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#supplying_request_options |
Beta Was this translation helpful? Give feedback.
-
it would be nice if we could use both. |
Beta Was this translation helpful? Give feedback.
-
I prefer the uppercase methods from a DX standpoint, since it matches the known convention for HTTP methods. |
Beta Was this translation helpful? Give feedback.
-
I do agree and think this will help new Svelte devs adopt endpoints, if they're already familiar with HTTP generally |
Beta Was this translation helpful? Give feedback.
-
Looks good and make totally sense. 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
And what are the types(ript) of paramaters on functions? like in load() ? |
Beta Was this translation helpful? Give feedback.
-
I changed http methods to uppercase and I am getting this error |
Beta Was this translation helpful? Give feedback.
-
Wow this is really annoying breaking change without any particular good reason. "it would be a mildly annoying breaking change". No! Surely you know that the downstream effects might be more than you imagine. People that are dealing with largish unfamiliar code bases and the many many different ways you can syntatically write the concept "export function get(" coupled with the fact that - as you say - "get" is incredibly common method name across a large number of contexts even "get(" is very common. It is not at all easy to find. If this was needed for some reason, fine. But just because it seemed like a nice jape. Ugh. PS in the middle of (failing to) get someone elses app building because of this stupid breaking change I guess I'll just downgrade sveltekit |
Beta Was this translation helpful? Give feedback.
-
Couldn't you have just added a non-breaking option instead of coupling case-sensitive function name to HTTP methods? |
Beta Was this translation helpful? Give feedback.
-
Update:
export function GET() {...}
etc) #5367I had innocently gone through life believing that uppercase HTTP methods were a mere convention until #5354 led me to whatwg/fetch#50. Now I know better —
PATCH
andpatch
are not the same.Which makes me wonder if we should make our endpoints more HTTP-ish:
Couple of things to point out about this:
send
DELETE
handlers are calleddel
instead ofdelete
, since whereasdelete
is a keyword in JavaScript,DELETE
is not. I loathe this aspect of our design; it almost made me want to have a default export with handlers as properties instead of exporting named functions, despite the useless extra level of indentation it would forceget
is a fairly common function/method name (often paired with aset
); in this world, handlers are very easy to search for in a codebaseOn the other hand:
WDYT?
Beta Was this translation helpful? Give feedback.
All reactions