shinosaki / hono-kv-session

Stateful session middleware for Hono. Works on Cloudflare Workers, Node.js, Bun, etc.
https://hono-kv-session.la1n.workers.dev
9 stars 1 forks source link

Deno KV: c.session.value not unpacked #5

Closed Rhal95 closed 10 months ago

Rhal95 commented 10 months ago

Hi ๐Ÿ‘‹

Deno KV will always return a Deno.KvEntry when using kv.get(). Even when no value is found for the key. If no value is found, the value in the entry is null. The SessionManager does not unpack this value and puts the Deno.KvEntry into c.session.value. This means I have to unpack the value myself every time I want to access it. This also means I can not use the renew and regenerate functions. Those will just put the session value back into the createSession function which will nest the Deno.KvEntry in another Deno.KvEntry.

If you want I can submit a PR for this tomorrow.

Rhal95 commented 10 months ago

Hi again ๐Ÿ‘‹ I fixed the unpacking of the KvEntry for Deno KV. Please take a look at the PR and tell me if everything is okay. Thank you.

shinosaki commented 10 months ago

Thank you for pull request! Merged it.๐Ÿ‘ Sorry for the delay๐Ÿ™‡๐Ÿ™‡

shinosaki commented 10 months ago

DenoKV ใฎ get() ใฏใ€ๅ€คใ‚’ใใฎใพใพ่ฟ”ใ•ใš KvEntryMaybe ใ‚’่ฟ”ใ™ไป•ๆง˜ใงใ—ใŸใ€‚

{
  key: KvKey,
  value: null,
  versionstamp: null
}

ใ“ใฎใƒ—ใƒซใƒชใ‚ฏใง c.session.value ใซ value ใ‚’ไปฃๅ…ฅใ™ใ‚‹ใ‚ˆใ†ไฟฎๆญฃใ•ใ‚Œใพใ—ใŸใ€‚