Skip to content

feat(server): delete cookie helper - #820

Merged
dinwwwh merged 1 commit into
mainfrom
feat/server/delete-cookie-helper
Aug 3, 2025
Merged

feat(server): delete cookie helper#820
dinwwwh merged 1 commit into
mainfrom
feat/server/delete-cookie-helper

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Aug 3, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added the ability to delete cookies, allowing cookies to be removed from the response.
  • Documentation

    • Updated cookie management examples to clearly distinguish between request and response headers.
    • Added examples demonstrating how to delete cookies in documentation.
  • Tests

    • Added comprehensive tests for cookie deletion, including handling of options and edge cases.

@vercel

vercel Bot commented Aug 3, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2025 1:51am

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 3, 2025
@coderabbitai

coderabbitai Bot commented Aug 3, 2025

Copy link
Copy Markdown

Walkthrough

A new deleteCookie helper function was introduced for managing cookie deletion, with corresponding updates to documentation and tests. Examples in the documentation now clearly separate request and response headers. The test suite was expanded to include comprehensive tests for deleteCookie, ensuring correct behavior and error handling.

Changes

Cohort / File(s) Change Summary
Documentation Update
apps/content/docs/helpers/cookie.md
Updated examples to separate request and response headers, included deleteCookie usage, and clarified context.
Helper Implementation
packages/server/src/helpers/cookie.ts
Added and exported the deleteCookie function for cookie removal, leveraging existing setCookie logic.
Test Suite Expansion
packages/server/src/helpers/cookie.test.ts
Added tests for deleteCookie, including normal, custom options, and undefined headers scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant CookieHelper

    Client->>Server: Sends request with cookies in reqHeaders
    Server->>CookieHelper: getCookie(reqHeaders, name)
    CookieHelper-->>Server: Returns cookie value

    Server->>CookieHelper: setCookie(resHeaders, name, value, options)
    CookieHelper-->>Server: Sets cookie in resHeaders

    Server->>CookieHelper: deleteCookie(resHeaders, name, options)
    CookieHelper->>setCookie: Calls setCookie with value="" and maxAge=0
    setCookie-->>CookieHelper: Sets expired cookie in resHeaders
    CookieHelper-->>Server: Cookie deleted
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

In the warren where cookies abound,
A new helper makes crumbs hit the ground.
With deleteCookie, old snacks disappear,
While docs and tests make intentions clear.
Rabbits rejoice, their burrows neat—
Out with the stale, in with the sweet! 🍪🐇

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/server/delete-cookie-helper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've added a new deleteCookie helper function to the server-side cookie utilities. This function simplifies the process of expiring cookies by setting their maxAge to zero, ensuring they are removed from the client's browser. This enhancement provides a more convenient and explicit way to manage cookie lifecycle.

Highlights

  • New deleteCookie Function: I've introduced a new deleteCookie utility function that simplifies the process of expiring HTTP cookies. This function internally leverages the existing setCookie function by setting the cookie's Max-Age to 0, effectively instructing the client to remove it.
  • Comprehensive Testing: To ensure the reliability of the new deleteCookie function, I've added a comprehensive suite of unit tests. These tests cover various scenarios, including basic cookie deletion, proper handling of additional cookie options (like path), and graceful behavior when provided with undefined headers.
  • Documentation Update: The documentation for cookie helpers has been updated to include the newly added deleteCookie function. I've also refined existing examples to clearly demonstrate its usage alongside setCookie and getCookie, improving overall clarity by distinguishing between request and response headers.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Aug 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a deleteCookie helper function, along with corresponding tests and documentation. The implementation is clean and follows best practices for cookie deletion. My review focuses on improving the clarity of the documentation examples, which are currently a bit confusing, and enhancing the robustness of the new tests. I've also suggested a minor stylistic improvement in the deleteCookie implementation itself.

Comment thread apps/content/docs/helpers/cookie.md
Comment thread apps/content/docs/helpers/cookie.md
Comment thread packages/server/src/helpers/cookie.test.ts
Comment thread packages/server/src/helpers/cookie.test.ts
Comment thread packages/server/src/helpers/cookie.ts
@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2025

Copy link
Copy Markdown
More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@820

@orpc/client

npm i https://pkg.pr.new/@orpc/client@820

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@820

@orpc/experimental-durable-event-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-event-iterator@820

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@820

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@820

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@820

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@820

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@820

@orpc/react

npm i https://pkg.pr.new/@orpc/react@820

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@820

@orpc/server

npm i https://pkg.pr.new/@orpc/server@820

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@820

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@820

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@820

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@820

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@820

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@820

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@820

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@820

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@820

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@820

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@820

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@820

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@820

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@820

commit: d109406

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a437cb and d109406.

📒 Files selected for processing (3)
  • apps/content/docs/helpers/cookie.md (2 hunks)
  • packages/server/src/helpers/cookie.test.ts (2 hunks)
  • packages/server/src/helpers/cookie.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/server/src/helpers/cookie.test.ts (1)
packages/server/src/helpers/cookie.ts (2)
  • setCookie (28-44)
  • deleteCookie (83-92)
🪛 Biome (2.1.2)
packages/server/src/helpers/cookie.ts

[error] 88-91: The function should not return a value because its return type is void.

The function is here:

'void' signals the absence of value. The returned value is likely to be ignored by the caller.

(lint/correctness/noVoidTypeReturn)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: publish-commit
  • GitHub Check: lint
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
packages/server/src/helpers/cookie.ts (1)

80-92: LGTM! Clean implementation of cookie deletion.

The function correctly implements cookie deletion by setting maxAge: 0, which is the standard approach to expire cookies immediately. The type safety with Omit<SetCookieOptions, 'maxAge'> prevents accidental override of the deletion behavior.

apps/content/docs/helpers/cookie.md (2)

11-11: LGTM! Good addition of deleteCookie to imports.

The import statement correctly includes the new deleteCookie function alongside existing helpers.


13-24: Excellent improvement in documentation clarity.

Separating request and response headers with distinct variable names (reqHeaders and resHeaders) makes the examples much clearer and helps developers understand the proper context for each operation.

packages/server/src/helpers/cookie.test.ts (2)

1-1: LGTM! Import statement correctly updated.

The import statement properly includes deleteCookie alongside existing functions.


117-138: Excellent comprehensive test coverage for deleteCookie.

The test suite covers all essential scenarios:

  • Basic deletion with maxAge: 0 verification
  • Options handling while correctly ignoring any provided maxAge
  • Graceful handling of undefined headers
  • Proper use of @ts-expect-error to document intentional type constraint testing

The tests validate both the functional behavior and type safety of the implementation.

Comment thread packages/server/src/helpers/cookie.ts
@dinwwwh
dinwwwh merged commit cf959ae into main Aug 3, 2025
11 checks passed
@dinwwwh
dinwwwh deleted the feat/server/delete-cookie-helper branch June 22, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant