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

Docs for Blitz RPC endpoint to the app directory #860

Merged
merged 22 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rpcApphanlder config
  • Loading branch information
siddhsuresh committed Jun 18, 2024
commit a730a333ffea8c6217a50b4f14bef3197b2836af
37 changes: 28 additions & 9 deletions app/pages/docs/rpc-config.mdx
Original file line number Diff line number Diff line change
@@ -75,7 +75,9 @@ module.exports = withBlitz({

## Logging Setup {#blitz-rpc-logging}

In your `[[...blitz]].ts` api file you can see the following settings in the `rpcHandler`
In your `[[...blitz]].ts` api file you can see the following settings in
the `rpcHandler`

```ts
logging?: {
/**
@@ -99,17 +101,35 @@ logging?: {
disablelevel?: "debug" | "info"
}
```

<Card type="note">
Blitz RPC defaults to:
- `verbose` to be true if it not configured.
- The `input` and `resolver completion time` will be logged with the `info` level.
- The `result` and `next.js serialization time` will be logged with the `debug` level.
Blitz RPC defaults to: - `verbose` to be true if it not configured. -
The `input` and `resolver completion time` will be logged with the
`info` level. - The `result` and `next.js serialization time` will be
logged with the `debug` level.
Copy link
Member

Choose a reason for hiding this comment

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

list formatting is broken

siddhsuresh marked this conversation as resolved.
Show resolved Hide resolved
</Card>


Example:

```ts
// app router (recommended)
// app/api/rpc/[[...blitz]]/route.ts
export default api(
rpcAppHandler({
onError: console.log,
formatError: (error) => {
error.message = `FormatError handler: ${error.message}`
return error
},
logging: {
verbose: true,
blockList: ["getCurrentUser", ...], //just write the resolver name [which is the resolver file name]
},
})
)

// pages router
// src/pages/api/rpc/[[...blitz]].ts
export default api(
rpcHandler({
onError: console.log,
@@ -125,6 +145,5 @@ export default api(
)
```

This is will enable verbose Blitz RPC logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList`


This is will enable verbose Blitz RPC logging for all resolvers except the
resolvers `getCurrentUser` and others mentioned in the `blockList`
Loading