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: Blitz RPC endpoint to the app directory #4341

Merged
merged 76 commits into from
Jul 1, 2024

Conversation

siddhsuresh
Copy link
Member

@siddhsuresh siddhsuresh commented May 22, 2024

What are the changes and their implications?

Usage:

// app/api/rpc/[[...blitz]]/route.ts
import {rpcAppHandler} from "@blitzjs/rpc"
import {withBlitzAuth} from "app/blitz-server"

export const {GET, POST, HEAD} = withBlitzAuth(rpcAppHandler())

If using only auth and not rpc in the route.ts files

//app/api/logout/route.ts
export const {POST} = withBlitzAuth({
  POST: async (_request, _params, ctx) => {
    const session = ctx.session
    await session.$revoke()

    return new Response(
      JSON.stringify({
        userId: session.userId,
      }),
      {status: 200},
    )
  },
})

Feature Checklist

Copy link

changeset-bot bot commented May 22, 2024

🦋 Changeset detected

Latest commit: 14b9e0f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
blitz Minor
@blitzjs/auth Major
@blitzjs/next Major
@blitzjs/rpc Major
@blitzjs/generator Major
next-blitz-auth Patch
@blitzjs/codemod Major
@blitzjs/config Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@siddhsuresh siddhsuresh changed the title feat: make rpchandler work with Request and return a Response feat: Blitz RPC endpoint to the app directory May 22, 2024
@siddhsuresh
Copy link
Member Author

!preview app-dir-blitz-rpc

.changeset/tidy-gorillas-confess.md Outdated Show resolved Hide resolved
.changeset/tidy-gorillas-confess.md Outdated Show resolved Hide resolved
Copy link
Member

@flybayer flybayer left a comment

Choose a reason for hiding this comment

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

.

siddhsuresh and others added 2 commits June 19, 2024 00:38
Co-authored-by: Brandon Bayer <b@bayer.ws>
.changeset/tidy-gorillas-confess.md Outdated Show resolved Hide resolved
.changeset/tidy-gorillas-confess.md Outdated Show resolved Hide resolved
@siddhsuresh
Copy link
Member Author

!preview app-dir-blitz-rpc

2 similar comments
@siddhsuresh
Copy link
Member Author

!preview app-dir-blitz-rpc

@siddhsuresh
Copy link
Member Author

!preview app-dir-blitz-rpc

Copy link
Contributor

Snapshot Release app-dir-blitz-rpc

@siddhsuresh siddhsuresh merged commit 3b10b13 into main Jul 1, 2024
29 checks passed
@siddhsuresh siddhsuresh deleted the siddharth/work-with-request branch July 1, 2024 18:11
@blitzjs-bot blitzjs-bot added this to Done in Toolkit Jul 1, 2024
@siddhsuresh siddhsuresh restored the siddharth/work-with-request branch July 1, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants