Skip to content

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 27, 2025

This PR introduces a new HTTPEvent interface as a subtype of H3Event:

interface HTTPEvent { req: ServerRequest }

(the real implementation supports generics and full type inference with auto-completion)

With this simplified interface, many built-in H3 utilities (e.g., setCookie, readValidatedBody) can be used outside of H3 usage:

import { getCookie } from "h3";

export default {
  fetch(req: Request) {
    return Response.json({
      cookie: getCookie({ req }, "test") || null,
    });
  },
};

To allow accessing unified context, a new getEventContext(event) utility exposed:

  • Uses H3Event.context if exists
  • Uses ServerRequest.context or initializes a new (shared) one to use

@pi0 pi0 changed the title feat: HTTPEvent for more agnostic utils feat: HTTPEvent for more agnostic usage Aug 27, 2025
Copy link

cloudflare-workers-and-pages bot commented Aug 27, 2025

Deploying h3dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4673afc
Status: ✅  Deploy successful!
Preview URL: https://b2ad3d7b.h3dev.pages.dev
Branch Preview URL: https://feat-http-event.h3dev.pages.dev

View logs

Copy link

codecov bot commented Aug 27, 2025

Codecov Report

❌ Patch coverage is 81.92771% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/utils/session.ts 69.69% 10 Missing ⚠️
src/utils/event.ts 58.33% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@pi0 pi0 merged commit 74132f9 into main Aug 27, 2025
4 of 5 checks passed
@pi0 pi0 deleted the feat/http-event branch August 27, 2025 11:57
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.

1 participant