1
0
mirror of synced 2026-02-03 18:01:02 -05:00

Compare commits

...

3 Commits

Author SHA1 Message Date
github-actions[bot]
da76acc90a Version Packages (beta) (#4167)
* Version Packages (beta)

* pnpm lock

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-07-05 20:46:08 +05:30
Siddharth Suresh
c5572bec6e blitz-auth: Fix webpack from following next-auth (#4160)
* fix webpack from following next-auth

* redo

* Create curvy-drinks-perform.md

* wrap with try catch

* fix build issue

* upgrade ci to pnpm 8

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-03 17:36:46 +00:00
Siddharth Suresh
727734955a Configure the Verbosity of Blitz RPC Logging (#4162)
* improve blitz rpc logging

* implement improved setup with jsdoc comments

* make it verbose by default

* change routePath to resolverName for easier use

* Update packages/blitz-rpc/src/index-server.ts

* rename to make language more inclusive

* set output as debug

* Create sixty-rockets-count.md

* Update sixty-rockets-count.md

* Update sixty-rockets-count.md

* fix verbose bug

* Apply suggestions from code review

Co-authored-by: Brandon Bayer <b@bayer.ws>

---------

Co-authored-by: Brandon Bayer <b@bayer.ws>
2023-07-03 22:57:34 +05:30
60 changed files with 2102 additions and 2236 deletions

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
blitz-auth: Fix webpack from following next-auth

View File

@@ -86,6 +86,7 @@
"curly-rules-speak",
"curly-seas-serve",
"curvy-days-attend",
"curvy-drinks-perform",
"cyan-bulldogs-heal",
"cyan-cars-greet",
"dirty-monkeys-greet",
@@ -259,6 +260,7 @@
"silly-peas-work",
"silly-shoes-agree",
"six-apricots-kick",
"sixty-rockets-count",
"slimy-humans-impress",
"slimy-needles-taste",
"slow-impalas-tap",

View File

@@ -0,0 +1,68 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
### Now we can configure Blitz RPC in the following way,
In your `[[...blitz]].ts` api file you can see the following settings
```ts
logging?: {
/**
* allowList Represents the list of routes for which logging should be enabled
* If whiteList is defined then only those routes will be logged
*/
allowList?: string[]
/**
* blockList Represents the list of routes for which logging should be disabled
* If blockList is defined then all routes except those will be logged
*/
blockList?: string[]
/**
* verbose Represents the flag to enable/disable logging
* If verbose is true then Blitz RPC will log the input and output of each resolver
*/
verbose?: boolean
/**
* disablelevel Represents the flag to enable/disable logging for a particular level
*/
disablelevel?: "debug" | "info"
}
```
```ts
import { rpcHandler } from "@blitzjs/rpc"
import { api } from "src/blitz-server"
export default api(
rpcHandler({
onError: console.log,
formatError: (error) => {
error.message = `FormatError handler: ${error.message}`
return error
},
logging: {
...
}
})
)
```
Example:
```ts
export default api(
rpcHandler({
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]
},
})
)
```
This is enable verbose blitz rpc logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList`

View File

@@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.2.4
with:
version: 7.33.0
version: 8.6.5
- name: Setup node
uses: actions/setup-node@v2
with:
@@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.2.4
with:
version: 7.33.0
version: 8.6.5
- name: Setup node
uses: actions/setup-node@v2
with:
@@ -70,7 +70,7 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@v2.2.4
with:
version: 7.33.0
version: 8.6.5
- name: Setup node@16
uses: actions/setup-node@v2
@@ -129,7 +129,7 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@v2.2.4
with:
version: 7.33.0
version: 8.6.5
- name: Setup node@${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v2

View File

@@ -1,5 +1,17 @@
# next-blitz-auth
## 0.1.1-beta.6
### Patch Changes
- Updated dependencies [c5572bec6]
- Updated dependencies [727734955]
- @blitzjs/auth@2.0.0-beta.30
- blitz@2.0.0-beta.30
- @blitzjs/rpc@2.0.0-beta.30
- @blitzjs/next@2.0.0-beta.30
- @blitzjs/config@2.0.0-beta.30
## 0.1.1-beta.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "next-blitz-auth",
"version": "0.1.1-beta.5",
"version": "0.1.1-beta.6",
"private": true,
"scripts": {
"blitz:dev": "next dev",

View File

@@ -30,7 +30,7 @@
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"next": "13.3.0",
"openid-client": "5.2.1",
"prisma": "4.6.1",

View File

@@ -31,7 +31,7 @@
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"next": "13.3.0",
"next-auth": "4.18.7",
"prisma": "4.6.1",

View File

@@ -8,5 +8,9 @@ export default api(
error.message = `FormatError handler: ${error.message}`
return error
},
// logging: {
// verbose: true,
// blockList: ["/getCurrentUser"],
// },
})
)

View File

@@ -17,14 +17,14 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "workspace:2.0.0-beta.30",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"delay": "5.0.0",
"next": "13.3.0",
"prisma": "4.6.1",

View File

@@ -17,11 +17,11 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "workspace:2.0.0-beta.30",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"lowdb": "3.0.0",
"next": "13.3.0",
"prisma": "4.6.1",

View File

@@ -16,11 +16,11 @@
"schema": "db/schema.prisma"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"lowdb": "3.0.0",
"next": "13.3.0",
"prisma": "4.6.1",
@@ -28,7 +28,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",

View File

@@ -11,10 +11,10 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
},
"dependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"blitz": "workspace:2.0.0-beta.30",
"next": "13.3.0",
"react": "18.2.0",
"react-dom": "18.2.0"

View File

@@ -17,12 +17,12 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "workspace:2.0.0-beta.30",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"lowdb": "3.0.0",
"next": "13.3.0",
"prisma": "4.6.1",

View File

@@ -16,11 +16,11 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"lowdb": "3.0.0",
"next": "13.3.0",
"prisma": "4.6.1",
@@ -28,7 +28,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",

View File

@@ -8,13 +8,13 @@
"clean": "rm -rf .turbo && rm -rf node_modules"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "workspace:2.0.0-beta.30",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"@prisma/client": "4.6.1",
"@tanstack/react-query": "4.0.10",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"next": "13.3.0",
"prisma": "4.6.1",
"react": "18.2.0",

View File

@@ -16,10 +16,10 @@
"schema": "db/schema.prisma"
},
"dependencies": {
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"lowdb": "3.0.0",
"next": "13.3.0",
"prisma": "4.6.1",
@@ -27,7 +27,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",

View File

@@ -7,10 +7,10 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
},
"dependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"blitz": "workspace:2.0.0-beta.30",
"next": "13.3.0",
"react": "18.2.0",
"react-dom": "18.2.0"

View File

@@ -7,10 +7,10 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
},
"dependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"blitz": "workspace:2.0.0-beta.30",
"next": "13.3.0",
"react": "18.2.0",
"react-dom": "18.2.0"

View File

@@ -16,11 +16,11 @@
"schema": "db/schema.prisma"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.29",
"@blitzjs/next": "workspace:2.0.0-beta.29",
"@blitzjs/rpc": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "workspace:2.0.0-beta.30",
"@blitzjs/next": "workspace:2.0.0-beta.30",
"@blitzjs/rpc": "workspace:2.0.0-beta.30",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.29",
"blitz": "workspace:2.0.0-beta.30",
"lowdb": "3.0.0",
"next": "13.3.0",
"prisma": "4.6.1",
@@ -28,7 +28,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",

View File

@@ -1,5 +1,14 @@
# @blitzjs/auth
## 2.0.0-beta.30
### Patch Changes
- c5572bec6: blitz-auth: Fix webpack from following next-auth
- Updated dependencies [c5572bec6]
- Updated dependencies [727734955]
- blitz@2.0.0-beta.30
## 2.0.0-beta.29
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/auth",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"homepage": "https://blitzjs.com/",
"repository": {
"type": "git",
@@ -50,7 +50,7 @@
"url": "0.11.0"
},
"peerDependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"next": "*",
"next-auth": "*",
"secure-password": "4.0.0"
@@ -67,7 +67,7 @@
}
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@testing-library/react": "13.4.0",
"@testing-library/react-hooks": "8.0.1",
"@types/cookie": "0.4.1",
@@ -75,7 +75,7 @@
"@types/jsonwebtoken": "8.5.8",
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"next": "13.3.0",
"next-auth": "4.18.7",
"react": "18.2.0",

View File

@@ -1,27 +1,30 @@
//@ts-nocheck
import fs from "fs-extra"
import path from "path"
export function withNextAuthAdapter(nextConfig) {
const config = Object.assign({}, nextConfig)
const nextAuthPath = path.dirname(require.resolve("next-auth"))
const webpack = (config) => {
config.resolve.alias = {
...config.resolve.alias,
"next-auth/core/lib/oauth/callback": path.join(nextAuthPath, "core/lib/oauth/callback.js"),
"next-auth/core/lib/oauth/authorization-url": path.join(
nextAuthPath,
"core/lib/oauth/authorization-url.js",
),
"next-auth/core/init": path.join(nextAuthPath, "core/init.js"),
try {
const nextAuthPath = path.dirname(require.resolve("next-auth"))
const webpack = (config) => {
config.resolve.alias = {
...config.resolve.alias,
"next-auth/core/lib/oauth/callback": path.join(nextAuthPath, "core/lib/oauth/callback.js"),
"next-auth/core/lib/oauth/authorization-url": path.join(
nextAuthPath,
"core/lib/oauth/authorization-url.js",
),
"next-auth/core/init": path.join(nextAuthPath, "core/init.js"),
}
return config
}
if (typeof nextConfig.webpack === "function") {
config.webpack = (config, options) => {
return nextConfig.webpack(webpack(config), options)
}
}
config.webpack = webpack
return config
} catch (e) {
return config
}
if (typeof nextConfig.webpack === "function") {
config.webpack = (config, options) => {
return nextConfig.webpack(webpack(config), options)
}
}
config.webpack = webpack
return config
}

View File

@@ -1,5 +1,14 @@
# @blitzjs/next
## 2.0.0-beta.30
### Patch Changes
- Updated dependencies [c5572bec6]
- Updated dependencies [727734955]
- blitz@2.0.0-beta.30
- @blitzjs/rpc@2.0.0-beta.30
## 2.0.0-beta.29
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/next",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"homepage": "https://blitzjs.com/",
"repository": {
"type": "git",
@@ -29,7 +29,7 @@
"eslint.js"
],
"dependencies": {
"@blitzjs/rpc": "2.0.0-beta.29",
"@blitzjs/rpc": "2.0.0-beta.30",
"@types/hoist-non-react-statics": "3.3.1",
"debug": "4.3.3",
"fs-extra": "10.0.1",
@@ -38,13 +38,13 @@
"supports-color": "8.1.1"
},
"peerDependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"next": "*",
"react": "*",
"tslog": "*"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@testing-library/dom": "8.13.0",
"@testing-library/jest-dom": "5.16.3",
"@testing-library/react": "13.4.0",
@@ -55,7 +55,7 @@
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"@types/testing-library__react-hooks": "4.0.0",
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"cross-spawn": "7.0.3",
"find-up": "4.1.0",
"next": "13.3.0",

View File

@@ -1,5 +1,79 @@
# @blitzjs/rpc
## 2.0.0-beta.30
### Patch Changes
- 727734955: ### Now we can configure Blitz RPC in the following way,
In your `[[...blitz]].ts` api file you can see the following settings
```ts
logging?: {
/**
* allowList Represents the list of routes for which logging should be enabled
* If whiteList is defined then only those routes will be logged
*/
allowList?: string[]
/**
* blockList Represents the list of routes for which logging should be disabled
* If blockList is defined then all routes except those will be logged
*/
blockList?: string[]
/**
* verbose Represents the flag to enable/disable logging
* If verbose is true then Blitz RPC will log the input and output of each resolver
*/
verbose?: boolean
/**
* disablelevel Represents the flag to enable/disable logging for a particular level
*/
disablelevel?: "debug" | "info"
}
```
```ts
import { rpcHandler } from "@blitzjs/rpc"
import { api } from "src/blitz-server"
export default api(
rpcHandler({
onError: console.log,
formatError: (error) => {
error.message = `FormatError handler: ${error.message}`
return error
},
logging: {
...
}
})
)
```
Example:
```ts
export default api(
rpcHandler({
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]
},
})
)
```
This is enable verbose blitz rpc logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList`
- Updated dependencies [c5572bec6]
- Updated dependencies [727734955]
- blitz@2.0.0-beta.30
## 2.0.0-beta.29
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/rpc",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"homepage": "https://blitzjs.com/",
"repository": {
"type": "git",
@@ -37,18 +37,18 @@
},
"peerDependencies": {
"@tanstack/query-core": "4.24.4",
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"next": "*",
"react": "*"
},
"devDependencies": {
"@blitzjs/auth": "2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/auth": "2.0.0-beta.30",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@tanstack/query-core": "4.24.4",
"@types/debug": "4.1.7",
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"next": "13.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -146,6 +146,59 @@ async function getResolverMap(): Promise<ResolverFiles | null | undefined> {
interface RpcConfig {
onError?: (error: Error) => void
formatError?: (error: Error) => Error
logging?: {
/**
* allowList Represents the list of routes for which logging should be enabled
* If allowList is defined then only those routes will be logged
*/
allowList?: string[]
/**
* blockList Represents the list of routes for which logging should be disabled
* If blockList is defined then all routes except those will be logged
*/
blockList?: string[]
/**
* verbose Represents the flag to enable/disable logging
* If verbose is true then Blitz RPC will log the input and output of each resolver
*/
verbose?: boolean
/**
* disablelevel Represents the flag to enable/disable logging for a particular level
*/
disablelevel?: "debug" | "info"
}
}
function isBlitzRPCVerbose(resolverName: string, config: RpcConfig, level: string) {
// blitz rpc is by default verbose - to keep current behaviour
if (!config.logging) {
return true
}
//if logging exists and verbose is not defined then default to true
if (config.logging && !("verbose" in config.logging)) {
return true
}
const isLevelDisabled = config.logging?.disablelevel === level
if (config.logging?.verbose) {
// If allowList array is defined then allow only those routes in allowList
if (config.logging?.allowList) {
if (config.logging?.allowList?.includes(resolverName) && !isLevelDisabled) {
return true
}
}
// If blockList array is defined then allow all routes except those in blockList
if (config.logging?.blockList) {
if (!config.logging?.blockList?.includes(resolverName) && !isLevelDisabled) {
return true
}
}
// if both allowList and blockList are not defined, then allow all routes
if (!config.logging?.allowList && !config.logging?.blockList && !isLevelDisabled) {
return true
}
return false
}
return false
}
export function rpcHandler(config: RpcConfig) {
@@ -159,10 +212,11 @@ export function rpcHandler(config: RpcConfig) {
const relativeRoutePath = (req.query.blitz as string[])?.join("/")
const routePath = "/" + relativeRoutePath
const resolverName = routePath.replace(/(\/api\/rpc)?\//, "")
const log = baseLogger().getSubLogger({
name: "blitz-rpc",
prefix: [routePath.replace(/(\/api\/rpc)?\//, "") + "()"],
prefix: [resolverName + "()"],
})
const customChalk = new chalk.Instance({
level: log.settings.type === "json" ? 0 : chalk.level,
@@ -213,11 +267,16 @@ export function rpcHandler(config: RpcConfig) {
? parse(`${req.query.meta}`)
: undefined,
})
log.info(customChalk.dim("Starting with input:"), data ? data : JSON.stringify(data))
if (isBlitzRPCVerbose(resolverName, config, "info")) {
log.info(customChalk.dim("Starting with input:"), data ? data : JSON.stringify(data))
}
const startTime = Date.now()
const result = await resolver(data, (res as any).blitzCtx)
const resolverDuration = Date.now() - startTime
log.info(customChalk.dim("Result:"), result ? result : JSON.stringify(result))
if (isBlitzRPCVerbose(resolverName, config, "debug")) {
log.debug(customChalk.dim("Result:"), result ? result : JSON.stringify(result))
}
const serializerStartTime = Date.now()
const serializedResult = superjsonSerialize(result)
@@ -231,21 +290,26 @@ export function rpcHandler(config: RpcConfig) {
result: serializedResult.meta,
},
})
log.debug(
customChalk.dim(
`Next.js serialization:${prettyMs(Date.now() - nextSerializerStartTime)}`,
),
)
if (isBlitzRPCVerbose(resolverName, config, "debug")) {
log.debug(
customChalk.dim(
`Next.js serialization:${prettyMs(Date.now() - nextSerializerStartTime)}`,
),
)
}
const serializerDuration = Date.now() - serializerStartTime
const duration = Date.now() - startTime
log.debug(
customChalk.dim(
`Finished: resolver:${prettyMs(resolverDuration)} serializer:${prettyMs(
serializerDuration,
)} total:${prettyMs(duration)}`,
),
)
if (isBlitzRPCVerbose(resolverName, config, "info")) {
log.info(
customChalk.dim(
`Finished: resolver:${prettyMs(resolverDuration)} serializer:${prettyMs(
serializerDuration,
)} total:${prettyMs(duration)}`,
),
)
}
newLine()
return

View File

@@ -1,5 +1,78 @@
# blitz
## 2.0.0-beta.30
### Patch Changes
- c5572bec6: blitz-auth: Fix webpack from following next-auth
- 727734955: ### Now we can configure Blitz RPC in the following way,
In your `[[...blitz]].ts` api file you can see the following settings
```ts
logging?: {
/**
* allowList Represents the list of routes for which logging should be enabled
* If whiteList is defined then only those routes will be logged
*/
allowList?: string[]
/**
* blockList Represents the list of routes for which logging should be disabled
* If blockList is defined then all routes except those will be logged
*/
blockList?: string[]
/**
* verbose Represents the flag to enable/disable logging
* If verbose is true then Blitz RPC will log the input and output of each resolver
*/
verbose?: boolean
/**
* disablelevel Represents the flag to enable/disable logging for a particular level
*/
disablelevel?: "debug" | "info"
}
```
```ts
import { rpcHandler } from "@blitzjs/rpc"
import { api } from "src/blitz-server"
export default api(
rpcHandler({
onError: console.log,
formatError: (error) => {
error.message = `FormatError handler: ${error.message}`
return error
},
logging: {
...
}
})
)
```
Example:
```ts
export default api(
rpcHandler({
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]
},
})
)
```
This is enable verbose blitz rpc logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList`
- @blitzjs/generator@2.0.0-beta.30
## 2.0.0-beta.29
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "blitz",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"homepage": "https://blitzjs.com/",
"repository": {
"type": "git",
@@ -30,7 +30,7 @@
"blitz": "bin/blitz"
},
"dependencies": {
"@blitzjs/generator": "2.0.0-beta.29",
"@blitzjs/generator": "2.0.0-beta.30",
"@mrleebo/prisma-ast": "0.2.6",
"@types/global-agent": "2.1.1",
"arg": "5.0.1",
@@ -80,7 +80,7 @@
"watchpack": "2.1.1"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.29",
"@blitzjs/config": "workspace:2.0.0-beta.30",
"@types/cookie": "0.4.1",
"@types/cross-spawn": "6.0.2",
"@types/debug": "4.1.7",

View File

@@ -1,5 +1,14 @@
# @blitzjs/codemod
## 2.0.0-beta.30
### Patch Changes
- Updated dependencies [c5572bec6]
- Updated dependencies [727734955]
- blitz@2.0.0-beta.30
- @blitzjs/generator@2.0.0-beta.30
## 2.0.0-beta.29
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/codemod",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"scripts": {
"build": "unbuild",
"dev": "watch unbuild src --wait=0.2",
@@ -25,9 +25,9 @@
"@babel/plugin-proposal-class-properties": "7.17.12",
"@babel/plugin-syntax-jsx": "7.17.12",
"@babel/plugin-syntax-typescript": "7.17.12",
"@blitzjs/generator": "2.0.0-beta.29",
"@blitzjs/generator": "2.0.0-beta.30",
"arg": "5.0.1",
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"chalk": "^4.1.0",
"cross-spawn": "7.0.3",
"debug": "4.3.3",

View File

@@ -1,5 +1,7 @@
# @blitzjs/config
## 2.0.0-beta.30
## 2.0.0-beta.29
## 2.0.0-beta.28

View File

@@ -1,7 +1,7 @@
{
"name": "@blitzjs/config",
"private": true,
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"license": "MIT",
"dependencies": {
"@typescript-eslint/eslint-plugin": "5.42.1",

View File

@@ -1,5 +1,7 @@
# @blitzjs/generator
## 2.0.0-beta.30
## 2.0.0-beta.29
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/generator",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"homepage": "https://blitzjs.com/",
"repository": {
"type": "git",
@@ -54,7 +54,7 @@
"zod": "3.20.2"
},
"devDependencies": {
"@blitzjs/config": "2.0.0-beta.29",
"@blitzjs/config": "2.0.0-beta.30",
"@juanm04/cpx": "2.0.1",
"@types/babel__core": "7.1.19",
"@types/diff": "5.0.2",

View File

@@ -25,7 +25,7 @@
"@typescript-eslint/parser": "5.9.1"
},
"devDependencies": {
"@blitzjs/config": "2.0.0-beta.29",
"@blitzjs/config": "2.0.0-beta.30",
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"react": "18.2.0",

3727
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,6 +24,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29"
"blitz": "2.0.0-beta.30"
}
}

View File

@@ -24,6 +24,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29"
"blitz": "2.0.0-beta.30"
}
}

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0",
"uuid": "^8.3.1"
},

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,6 +23,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29"
"blitz": "2.0.0-beta.30"
}
}

View File

@@ -22,6 +22,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29"
"blitz": "2.0.0-beta.30"
}
}

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,6 +22,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29"
"blitz": "2.0.0-beta.30"
}
}

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0",
"uuid": "^8.3.1"
},

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.29",
"blitz": "2.0.0-beta.30",
"jscodeshift": "0.13.0"
},
"devDependencies": {