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

implement onRequest/onBeforeRequest #36

Closed
threepointone opened this issue Jan 29, 2023 · 1 comment
Closed

implement onRequest/onBeforeRequest #36

threepointone opened this issue Jan 29, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@threepointone
Copy link
Contributor

export type PartyKitServer<Initial = unknown> = {
  onConnect: (ws: WebSocket, room: PartyKitRoom) => void | Promise<void>;
  onBeforeConnect?: (req: Request) => Initial | Promise<Initial>;
  // this part is new
  onRequest?: (
    req: Request,
    room: PartyKitRoom
  ) => Response | Promise<Response>;
  onBeforeRequest?: (req: Request) => void | Request | Promise<void | Request>;
  // ^ notice how this returns a Request, which is then passed to onRequest
  // giving you an opportunity to pass data in the request itself
};

twitter thread with some more context https://twitter.com/partykit_io/status/1618620327915032576

@threepointone
Copy link
Contributor Author

This is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant