Skip to content
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

feat: add useCookie and setCookie utils #17

Closed
wants to merge 6 commits into from

Conversation

farnabaz
Copy link
Contributor

I've added two utility function to work with cookies.

  • useCookie: Read and parse cookies from request
  • useCookieWrite: it receives the response object and return a function to manipulate response header and set Set-Cookie header.

src/cookie.ts Outdated Show resolved Hide resolved
src/cookie.ts Outdated Show resolved Hide resolved
src/cookie.ts Outdated Show resolved Hide resolved
src/cookie.ts Outdated Show resolved Hide resolved
const cookieObject = Object.fromEntries(cookieEnteries)

// @ts-ignore
req.cookie = cookieObject
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add an TS assertion that extends the Request object once this function has been called...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache value shouldn't be exposed or implicitly directly accessed.

farnabaz and others added 4 commits December 15, 2020 13:35
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Daniel Roe <daniel@roe.dev>
@pi0 pi0 changed the title feat: add utility to work with cookies feat: add useCookie and setCookie utils Dec 15, 2020
@pi0 pi0 closed this in 088f413 Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants