hono
hono copied to clipboard
Make argument order for getSignedCookie the same as setSignedCookie in cookie helper
What is the feature you are proposing?
I spent a while trying to debug why getSignedCookie() kept returning undefined. It turns out I had the argument order wrong because I assumed it was the same order as setSignedCookie().
setSignedCookie has this order
setSignedCookie(
c,
'cookie_name',
'cookie value',
'my-cookie-secret',
{} // cookie options
)
Whereas getSignedCookie has the cookie name and the secret order swapped.
getSignedCookie(
c,
'my-cookie-secret',
'cookie_name'
)
Unless I'm mistaken, you always have to specify both the name and the secret for a signed cookie, so I don't think you'd have an optional arg situation here.
So I propose that in Hono 5 a breaking change be introduced into the cookie helper that changes the order of the args for getSignedCookie to reflect the order in setSignedCookie.