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

Bri 1 pulse support #57

Merged
merged 8 commits into from Nov 13, 2023
Merged

Bri 1 pulse support #57

merged 8 commits into from Nov 13, 2023

Conversation

JoeRoddy
Copy link
Collaborator

@JoeRoddy JoeRoddy commented Nov 13, 2023

This PR:

  • adds the ability to use a websocket server for handling Bridg requests

    • can be configured simply by passing a ws url as your generator api:
    generator bridg {
      api = "ws://localost:3000/api/bridg"
      pulse = true
    }
  • adds support for the Prisma pulse extension, for listening to realtime data changes. to use this feature, you must:

    • use a websocket api
    • pass pulse = true in the bridg generator
    • extend your prisma client with pulse before passing it to Bridg for handling an incoming request:
    const db = new PrismaClient().$extends.withPulse({ apiKey: PULSE_API_KEY })) as unknown as PrismaClient;

An example socket server implementation can be viewed here:
https://github.com/JoeRoddy/pulse-chat-demo/blob/main/src/pages/api/socket.ts

In the future, I would like to simplify this to hide some of these complexities of managing subscriptions and replying to websocket messages.

  • adds a test suite to validate pulse subscriptions obey Bridg rules

@JoeRoddy JoeRoddy merged commit 71dcd53 into main Nov 13, 2023
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

1 participant