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

Compare commits

..

62 Commits

Author SHA1 Message Date
github-actions[bot]
99541848b3 Version Packages (beta) (#4258)
* Version Packages (beta)

* pnpm lock fix

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-11-29 00:21:19 +05:30
Siddharth Suresh
09e0c68db9 Add logic to auto authorize role with usage of redirectAuthenticatedTo (#4257)
* add logic to auto handle role with usage of `redirectAuthenticatedTo`

* Create hot-knives-vanish.md

* fix `globalThis.__BLITZ_GET_RSC_CONTEXT` being overriden

* pnpm lock fix
2023-11-28 17:58:39 +00:00
github-actions[bot]
fb232d126e Version Packages (beta) (#4227)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-10-30 18:48:22 +05:30
Siddharth Suresh
b97366c427 Remove unintended dependency on next-auth (#4235)
* export `next-auth` and all its requirements in a sub-directory

* Create modern-insects-raise.md

* undo changes to `secure-password` adapter

* try another way

* Update .changeset/modern-insects-raise.md

* Update .changeset/modern-insects-raise.md

* patch next-auth
2023-10-30 18:41:44 +05:30
Blitz.js Bot
11eeebee67 (meta) added @potikhanovsergey as contributor 2023-10-25 12:29:05 -04:00
Siddharth Suresh
c89cb943bb Upgrade next, prisma and zod to latest versions (#4237)
* upgrade next, prisma and zod to latest versions

* Create green-years-behave.md
2023-10-24 13:26:40 +00:00
Siddharth Suresh
3bcbad1a91 invoke with RPC Logger (#4229)
* add logging to rsc invoke and decouple auth from rpc again

* implement object chaining

* add `onInvokeError` options to catch errors without manual wrapping

* rename `LoggerOptions` to `RpcLoggerOptions`

* spacing

* fix error typed to `any`

* update class code

* tests working again

* add last test case proving working modal of roles

* Create moody-pandas-do.md

* Apply suggestions from code review

* blitz invoke logger
2023-10-24 18:48:11 +05:30
Siddharth Suresh
98d04ed613 Recipes: Map Repo link to this repository (#4228)
* map repolink of recipies to main repo

* Create pretty-snakes-search.md
2023-10-15 14:21:11 +05:30
Siddharth Suresh
cee2dec179 Authenticate does not work with roles (#4225)
* fix logic to test the role

* add tests

* pnpm lock

* Create afraid-ligers-build.md

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-05 20:26:42 +05:30
Siddharth Suresh
aec1bb076b blitz-next: Fix next/head warning in app directory (#4176)
* feat: Load Head lazyily using `dynamic`

* feat: upgrate turbo and fix layout.tsx

* fix: pnpm lock version

* Create chatty-scissors-jump.md

* Update .changeset/chatty-scissors-jump.md

* fix: move `dynamic` call to the top of the file

* add loading state to be null and no ssr
2023-10-05 20:12:26 +05:30
Blitz.js Bot
2c72af7175 (meta) added @Zamfi99 as contributor 2023-10-05 10:24:23 -04:00
Zamfira Costin-Andrei
465a5c0720 Fix for Tailwind recipe (#4165)
* Tailwind recipe: fixed tailwind.config.js

* Tailwind recipe: change dependecies to devDependecies

* Update recipes/tailwind/templates/config/tailwind.config.js

* Create neat-gorillas-switch.md

* pnpm lock fix

---------

Co-authored-by: Brandon Bayer <b@bayer.ws>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-10-05 14:24:18 +00:00
github-actions[bot]
353af3fae6 Version Packages (beta) (#4216)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-10-03 12:07:42 +05:30
Siddharth Suresh
3ddb57072b Update location of resolve-href in next 13.5.2 (#4222)
* upgrade to next 13.5.2 and update location of internal function

* Create lucky-teachers-sleep.md

* fix bootupMarkers

* fix issues with qm integration test

* Update integration-tests/utils/next-test-utils.ts

* next.js generated stuff

* Update .changeset/lucky-teachers-sleep.md

* remove unnecessary next lints to the integration-tests

* Update main.yml

* Revert "remove unnecessary next lints to the integration-tests"

This reverts commit 3226b2e3ba.
2023-10-03 12:02:46 +05:30
Siddharth Suresh
8477d44aa7 Update Flightcontrol logo formatting 2023-09-19 23:18:53 +05:30
Siddharth Suresh
6802c67809 [Internal] Update Flightcontrol logo (#4220) 2023-09-19 23:00:39 +05:30
Siddharth Suresh
fe8c937d24 Remove rouge console.log from codegen (#4215) 2023-09-11 23:53:47 +05:30
Kevin Østerkilde
30fd613164 feat(cli): remove unnecessary language selector step (#4214) 2023-09-11 19:14:51 +05:30
github-actions[bot]
9a5ce2e8ea Version Packages (beta) (#4212)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-06 16:39:31 +05:30
Blitz.js Bot
81290b478c (meta) added @rodobre as contributor 2023-09-06 06:54:22 -04:00
rodobre
19898a4886 Fix for tslog error logging (#4208)
* Added: Fix for tslog error logging

* Create nervous-shrimps-serve.md

---------

Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-06 10:54:17 +00:00
David
6811eab1aa Add .tsx & .jsx file extensions for resolvers (#4209)
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-09-06 16:16:19 +05:30
Siddharth Suresh
022392c123 fixes: Blitz template (#4211) 2023-09-05 19:37:55 +05:30
Siddharth Suresh
e3522d65ef sponser: update asset names 2023-08-25 12:30:58 +05:30
Siddharth Suresh
cb1600a821 sponsor: update Byteflow Logo 2023-08-25 12:23:12 +05:30
github-actions[bot]
e1bffdf3d6 Version Packages (beta) (#4197)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-08-17 23:41:49 +05:30
Siddharth Suresh
8b01175b47 blitz-auth: useAuthenticatedBlitzContext returns AuthenticatedCtx (#4198)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2023-08-17 13:29:31 +05:30
Blitz.js Bot
0f1beb55b7 (meta) added @justinsmid as contributor 2023-08-14 12:35:36 -04:00
Justin Smid
82649f3415 Upgrade tslog dependency from 4.8.2 to 4.9.0 (#4180)
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-08-14 22:05:31 +05:30
Blitz.js Bot
231c2ff5ab (meta) added @maciej-ka as contributor 2023-08-14 12:26:03 -04:00
Maciej Kasprzyk
47c6b62dcb docs: add a name column to generate all examples (#4181)
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-08-14 21:55:58 +05:30
Siddharth Suresh
cf393786c0 Fix CI: remove workspace from package.json (#4196) 2023-08-14 21:35:52 +05:30
Siddharth Suresh
8d29b8afa9 sponser: add Byteflow as a bronze sponsor 2023-08-04 00:53:41 +05:30
Siddharth Suresh
f8bf8af28f sponser: add Byteflow logo 2023-08-04 00:43:40 +05:30
github-actions[bot]
8255172940 Version Packages (beta) (#4177)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-07-21 01:52:20 +05:30
Siddharth Suresh
90f1741dac blitz-auth: Update Prisma Adapter for v5 (#4174)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-20 22:16:28 +05:30
Siddharth Suresh
df3265b854 blitz-rpc: Cleanup Method for Event Listeners (#4173)
* feat: logic to cleanup potential memory leak

* styling: add space

* Create poor-crabs-drum.md
2023-07-20 16:36:08 +00:00
Datner
0ba2f4e77a update monorepo tooling (#4169)
* chore: add nix

This could help contributers... contribute!

* build: use turborepo pipelines for coordination

instead of hacking it with sleeps and such....

* chore: update dev script

now we're cooking with gas! no more hacks, no more awkward flags

* chore: update pnpm version requirement

you want to support v6?? then use a v6-compatible pnpm version

* chore: update pnpm-lock
2023-07-12 13:13:51 +00:00
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
github-actions[bot]
831a493ab6 Version Packages (beta) (#4159)
* Version Packages (beta)

* updat 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-06-14 18:12:23 +00:00
Siddharth Suresh
b6b9a1c5a4 (fix) Next-Auth integration (#4153)
* fix next-auth integration

* Create small-monkeys-battle.md

* Update .changeset/small-monkeys-battle.md

* add a postinstall script for good measure

* add a postinstall script for good measure

* fix lock file

* upgrade pnpm

* fix version

* fix build error

* suggessions

* fix pnpm lock

* fix pnpm lock

* Update main.yml

* Update apps/toolkit-app/next.config.js

* next-auth working again

* Update apps/toolkit-app/.env

* Update packages/blitz-auth/src/server/auth-sessions.ts

* Update packages/blitz-auth/src/server/auth-sessions.ts
2023-06-14 22:54:48 +05:30
Siddharth Suresh
61888d1a30 fix: blitz logging formatting (#4158)
* fix blitz logging setup

* changeset

* Update packages/blitz/src/logging.ts
2023-06-13 13:04:23 +00:00
Sakamoto, Kazunori
7aef610d85 fix(@blitzjs/generator): make Next.js version pinning to 13.4.5 (#4150)
* fix: make Next.js version stick to 13.3.4

* fix: upgrade Next.js from 13.3.4 to 13.4.5

---------

Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-06-12 15:12:40 +05:30
Siddharth Suresh
b266254247 Revert "fix log showing path"
This reverts commit 67e00d9108.
2023-06-12 12:44:45 +05:30
Siddharth Suresh
67e00d9108 fix log showing path 2023-06-12 12:40:54 +05:30
github-actions[bot]
d25c965bc8 Version Packages (beta) (#4144)
* Version Packages (beta)

* pnpm lock

* fix worlfow pnpm version

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-06-09 23:54:35 +05:30
Siddharth Suresh
1bb3a65566 (fix): Stop exporting useAuthenticatedBlitzContext from @blitzjs/auth (#4157)
* Remove unnecessary exports from @blitzjs/auth

* add changeset

* allow exporting getBlitzContext as we need it for blitz rpc

* Update .changeset/moody-crews-travel.md

---------

Co-authored-by: Brandon Bayer <b@bayer.ws>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-09 17:01:55 +00:00
Blitz.js Bot
28b0ffeb5f (meta) added @jayu as contributor 2023-06-09 12:52:10 -04:00
Jakub Mazurek
c7ac86b857 fix: enormous memory consumption of the dev server (#4148)
* fix: enormous dev server memory consumption

* chore: add changeset file

* add resolversDynamicImport configuration

* make vercel default to true

* imporve the changelog

* Update .changeset/good-oranges-pretend.md

* make code cleaner

* a fix and refactor

* fix build

---------

Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2023-06-09 16:52:04 +00:00
Siddharth Suresh
5166e5e037 (feat) upgrade tslog (#4154)
* upgrade tslog

* Create big-turtles-tease.md

* pnpm lock

* fix build issue

* upgrade pnpm in the lock file to v8

* try again

* Update main.yml

* fix build

* fix

* again

* fix spacing
2023-06-05 21:11:34 +05:30
Siddharth Suresh
2533caf484 (fix): Fix the Type error in RpcServerPlugin (#4152)
* fix type error

* changeset
2023-06-05 19:31:27 +05:30
Blitz.js Bot
85a71ffef9 (meta) added @nikola-wd as contributor 2023-05-31 11:36:16 -04:00
Blitz.js Bot
803f533a3d (meta) added @nerixim as contributor 2023-05-31 11:21:39 -04:00
Blitz.js Bot
63ee9423a9 (meta) added @GHKEN as contributor 2023-05-11 12:06:35 -04:00
Tetsuya Fukuda
89446b3656 support both directory style in tailwind recipe (#4137)
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-05-11 21:36:30 +05:30
github-actions[bot]
5a64f1c39c Version Packages (beta) (#4135)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-05-01 23:33:32 +05:30
Blitz.js Bot
fa30de4599 (meta) added @gjmoed as contributor 2023-05-01 13:39:26 -04:00
G.J. Moed
3d004dc415 Adjust codegen logic for suspense patch (#4138)
Co-authored-by: Brandon Bayer <b@bayer.ws>
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-05-01 23:09:20 +05:30
Blitz.js Bot
08fbede75e (meta) added @dbrxnds as contributor 2023-05-01 12:30:21 -04:00
David
eda14fa8aa Add formatError property to Blitz server- & rpchandler setup (#4124)
Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-05-01 22:00:15 +05:30
196 changed files with 9371 additions and 6129 deletions

View File

@@ -3896,6 +3896,114 @@
"doc",
"code"
]
},
{
"login": "dbrxnds",
"name": "David",
"avatar_url": "https://avatars.githubusercontent.com/u/32268383?v=4",
"profile": "https://github.com/dbrxnds",
"contributions": [
"doc",
"code",
"test"
]
},
{
"login": "gjmoed",
"name": "G.J. Moed",
"avatar_url": "https://avatars.githubusercontent.com/u/4458993?v=4",
"profile": "https://github.com/gjmoed",
"contributions": [
"doc",
"code"
]
},
{
"login": "GHKEN",
"name": "Tetsuya Fukuda",
"avatar_url": "https://avatars.githubusercontent.com/u/5304351?v=4",
"profile": "https://ghken.com",
"contributions": [
"doc",
"code"
]
},
{
"login": "nerixim",
"name": "Nikita Kamaev",
"avatar_url": "https://avatars.githubusercontent.com/u/26106502?v=4",
"profile": "https://github.com/nerixim",
"contributions": [
"doc"
]
},
{
"login": "nikola-wd",
"name": "Nikola Ivanov",
"avatar_url": "https://avatars.githubusercontent.com/u/11588823?v=4",
"profile": "https://webredone.com/",
"contributions": [
"doc"
]
},
{
"login": "jayu",
"name": "Jakub Mazurek",
"avatar_url": "https://avatars.githubusercontent.com/u/11561585?v=4",
"profile": "jayu.dev",
"contributions": [
"doc",
"code"
]
},
{
"login": "maciej-ka",
"name": "Maciej Kasprzyk",
"avatar_url": "https://avatars.githubusercontent.com/u/5403694?v=4",
"profile": "https://github.com/maciej-ka",
"contributions": [
"doc",
"code"
]
},
{
"login": "justinsmid",
"name": "Justin Smid",
"avatar_url": "https://avatars.githubusercontent.com/u/34271675?v=4",
"profile": "https://github.com/justinsmid",
"contributions": [
"doc",
"code"
]
},
{
"login": "rodobre",
"name": "rodobre",
"avatar_url": "https://avatars.githubusercontent.com/u/52138375?v=4",
"profile": "https://github.com/rodobre",
"contributions": [
"doc",
"code"
]
},
{
"login": "Zamfi99",
"name": "Zamfira Costin-Andrei",
"avatar_url": "https://avatars.githubusercontent.com/u/19189337?v=4",
"profile": "https://github.com/Zamfi99",
"contributions": [
"doc",
"code"
]
},
{
"login": "potikhanovsergey",
"name": "Sergey",
"avatar_url": "https://avatars.githubusercontent.com/u/71494201?v=4",
"profile": "https://github.com/potikhanovsergey",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
Fix bug that did not allow `Page.authenicate = {role: "" }` to correctly work

View File

@@ -0,0 +1,9 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
"blitz": patch
"@blitzjs/generator": patch
---
(feat) upgrade tslog to v4.8.2

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/next": minor
"@blitzjs/rpc": minor
---
Add ability to format the error on the server before returning it to the client.

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/next": patch
"blitz": patch
---
blitz-next: Fix `next/head` used in app directory warning

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Update examples of generate all in docs to include one column in model.

View File

@@ -0,0 +1,9 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
Upgrade tslog to `4.9.0`.
This due a [tslog issue](https://github.com/fullstack-build/tslog/issues/227) that causes tslog to crash when attempting to log an error whose constructor expects more than one argument.

View File

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

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/rpc": patch
---
Fix return type of `requestMiddlewares` in `RpcServerPlugin`

View File

@@ -0,0 +1,8 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
blitz-auth: Support for Prisma v5
Internal: Make `handle` a required paramter while updating the `session` modal.

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/auth": patch
---
Updated `useAuthenticatedBlitzContext` to now return `AuthenticatedCtx`

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/next": minor
---
Fix the DYNAMIC_SERVER_USAGE error for Next.js 13.3.1+

View File

@@ -0,0 +1,26 @@
---
"@blitzjs/rpc": patch
---
Fixes enormous memory consumption of the dev server by changing the default import strategy to "require" instead of "import" which in webpack causes multiple chunks to be created for each import.
## Blitz Configuration
To configure this behaviour, you can add the following to your next.config.js:
```js
/**
* @type {import('@blitzjs/next').BlitzConfig}
**/
const config = {
blitz: {
resolversDynamicImport: true,
},
}
```
When `resolversDynamicImport` is set to `true`, the import strategy will be "import" instead of "require".
### On Vercel
If you are using Vercel, `resolversDynamicImport` will be set to `true` by default, since it is better for the separate chunks to be create for serverless lambdas.

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Upgrade next, prisma and zod to latest versions in a newly created app

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
Automatically authorize role with usage of `redirectAuthenticatedTo` in `useAuthenticatedBlitzContext` utility

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Make Next.js version stick to 13.4.5 when generating a new app

View File

@@ -0,0 +1,6 @@
---
"blitz": patch
---
- Removes language selection step from `blitz new` menu
- Make `formik` the default/recommended form library

View File

@@ -0,0 +1,10 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": major
"@blitzjs/rpc": patch
"blitz": patch
---
⚠️ Breaking Change:
Next.js version 13.5 or above is now required to use `@blitzjs/next`
Fix `Error: Cannot find module 'next/dist/shared/lib/router/utils/resolve-href'` by updating the location of next.js internal function.

View File

@@ -0,0 +1,13 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
Remove unintended dependency on next-auth by removing it from the core build of @blitzjs/auth
⚠️ Breaking Change for current users of `withNextAuthAdapter`
Update your import in `next.config.js` in the following way
```diff
-const { withNextAuthAdapter } = require("@blitzjs/auth")
+const { withNextAuthAdapter } = require("@blitzjs/auth/next-auth")

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/auth": minor
---
Stop exporting `useAuthenticatedBlitzContext` from `@blitzjs/auth` this must be imported from `app/blitz-server.ts` file in order to work correctly

View File

@@ -0,0 +1,9 @@
---
"@blitzjs/auth": patch
"@blitzjs/rpc": patch
"blitz": patch
---
- Introduce Blitz RPC's logging system to the `invoke` function which is the recommended way to call resolvers in nextjs `app` directory's react server components.
- This refactor also removes the re-introduced dependency between `blitz-auth` and `blitz-rpc`, allowing independent usage of `blitz-rpc`

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/recipe-tailwind": patch
---
Change tailwind recipe to install dependencies as devDependencies

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Fix for tslog error `TypeError: Cannot read properties of undefined (reading 'map')` while using custom errors.

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Allow `.tsx` & `.jsx` file extensions to be used for resolvers

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
blitz-rpc: Cleanup Event Listeners - Fix potential memory leak by cleaning up any residual event listeners set by blitz.

View File

@@ -53,8 +53,10 @@
"changesets": [
"afraid-dancers-juggle",
"afraid-ears-repair",
"afraid-ligers-build",
"big-boats-lay",
"big-phones-bow",
"big-turtles-tease",
"blue-flowers-peel",
"blue-pigs-tan",
"brave-zebras-deny",
@@ -70,12 +72,16 @@
"calm-papayas-protect",
"calm-tomatoes-drive",
"chatty-fireants-leave",
"chatty-gifts-whisper",
"chatty-scissors-jump",
"chilled-carrots-own",
"chilly-candles-care",
"chilly-jeans-fix",
"chilly-nails-nail",
"clean-hats-pump",
"clean-hounds-laugh",
"clean-walls-wink",
"clever-hornets-talk",
"clever-radios-lie",
"cool-doors-invent",
"cool-horses-check",
@@ -84,6 +90,7 @@
"curly-rules-speak",
"curly-seas-serve",
"curvy-days-attend",
"curvy-drinks-perform",
"cyan-bulldogs-heal",
"cyan-cars-greet",
"dirty-monkeys-greet",
@@ -108,8 +115,10 @@
"fast-toys-wash",
"fast-trainers-kneel",
"few-dogs-fetch",
"few-elephants-approve",
"few-hounds-worry",
"few-shrimps-leave",
"fifty-drinks-cry",
"flat-bees-approve",
"fluffy-coats-flow",
"fluffy-mangos-begin",
@@ -119,6 +128,8 @@
"four-meals-fry",
"four-radios-tickle",
"four-sheep-judge",
"fresh-camels-return",
"fresh-crews-chew",
"funny-cups-pay",
"fuzzy-bees-warn",
"fuzzy-dots-cross",
@@ -131,6 +142,7 @@
"gold-horses-punch",
"good-apes-drum",
"good-insects-wink",
"good-oranges-pretend",
"gorgeous-birds-warn",
"gorgeous-buses-scream",
"gorgeous-games-obey",
@@ -139,6 +151,7 @@
"great-terms-rescue",
"green-papayas-do",
"green-pillows-hammer",
"green-years-behave",
"happy-bees-lick",
"happy-hotels-visit",
"happy-paws-join",
@@ -152,6 +165,7 @@
"honest-comics-vanish",
"hot-cups-rhyme",
"hot-drinks-approve",
"hot-knives-vanish",
"hungry-baboons-swim",
"hungry-pens-collect",
"itchy-cups-double",
@@ -160,6 +174,7 @@
"khaki-ducks-cheer",
"khaki-pens-rest",
"kind-walls-suffer",
"large-hairs-battle",
"late-steaks-give",
"lazy-maps-sort",
"lemon-games-press",
@@ -168,6 +183,7 @@
"lemon-teachers-jam",
"light-donkeys-double",
"light-squids-draw",
"little-cycles-hang",
"little-pears-ring",
"long-bees-hope",
"long-dancers-jog",
@@ -177,24 +193,32 @@
"lovely-colts-share",
"lucky-cows-try",
"lucky-months-guess",
"lucky-teachers-sleep",
"lucky-years-turn",
"many-fans-fetch",
"mean-ears-speak",
"mean-gorillas-reply",
"modern-cameras-pull",
"modern-games-dream",
"modern-insects-raise",
"modern-ligers-behave",
"moody-bags-walk",
"moody-crews-travel",
"moody-pandas-do",
"moody-spoons-rhyme",
"moody-squids-cheer",
"nasty-suns-wash",
"neat-gorillas-switch",
"nervous-beds-travel",
"nervous-dolls-rule",
"nervous-shrimps-serve",
"new-coats-turn",
"new-olives-protect",
"nice-boxes-travel",
"nice-cats-lay",
"nice-deers-dream",
"nice-starfishes-live",
"nine-bags-rhyme",
"nine-birds-confess",
"nine-onions-admire",
"ninety-lies-press",
@@ -216,15 +240,18 @@
"plenty-gifts-provide",
"plenty-kiwis-greet",
"polite-lizards-love",
"poor-crabs-drum",
"poor-peas-lick",
"poor-penguins-look",
"poor-shrimps-think",
"poor-walls-relax",
"popular-teachers-pay",
"pretty-games-march",
"pretty-snakes-search",
"purple-donkeys-smash",
"purple-jars-begin",
"purple-singers-greet",
"quick-crews-occur",
"quick-cycles-confess",
"quick-dots-fetch",
"quiet-feet-travel",
@@ -239,6 +266,7 @@
"rotten-rocks-remember",
"rude-trainers-visit",
"serious-mugs-leave",
"shaggy-boxes-exercise",
"shaggy-carpets-brake",
"sharp-falcons-begin",
"sharp-olives-sip",
@@ -251,11 +279,13 @@
"silly-peas-work",
"silly-shoes-agree",
"six-apricots-kick",
"sixty-rockets-count",
"slimy-humans-impress",
"slimy-needles-taste",
"slow-impalas-tap",
"slow-walls-camp",
"slow-walls-poke",
"small-monkeys-battle",
"small-socks-confess",
"smooth-planets-admire",
"smooth-rice-clap",
@@ -285,6 +315,7 @@
"tall-radios-clean",
"tame-keys-reply",
"tame-pumpkins-nail",
"tame-rocks-unite",
"tasty-maps-fetch",
"tasty-news-collect",
"tasty-squids-sin",
@@ -322,7 +353,9 @@
"wicked-rings-walk",
"wise-eels-visit",
"wise-frogs-give",
"wise-lies-relate",
"wise-rabbits-complain",
"yellow-numbers-serve",
"young-birds-talk"
]
}

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/recipe-next-ui": patch
---
Add `framer-motion` as a dependency of `next-ui`

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Remove rouge `console.log` during start

View File

@@ -0,0 +1,9 @@
---
"@blitzjs/next": patch
"blitz": patch
"@blitzjs/generator": patch
---
- Updates `ts-log` peer dependency to `4.9.0`
- Removes `javascript` from `blitz new` menu
- Hot Fix the `Update Schema` when using blitz generator

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

@@ -0,0 +1,6 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
Fix Next-Auth integration: `Unable to use next-auth with provider: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]`

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Fix log formatting to not show the path of blitz rpc

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/recipe-tailwind": minor
---
support both directory style in tailwind recipe

View File

@@ -7,8 +7,8 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
jobs:
@@ -17,13 +17,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
- uses: pnpm/action-setup@v2.2.4
with:
version: 7.11.0
version: 8.6.5
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 18
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
@@ -38,13 +38,13 @@ jobs:
name: Build
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
- uses: pnpm/action-setup@v2.2.4
with:
version: 7.11.0
version: 8.6.5
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 18
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- name: Build
@@ -62,20 +62,20 @@ jobs:
- windows-latest
fail-fast: false
env:
NODE_VERSION: 16
NODE_VERSION: 18
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PNPM
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
uses: pnpm/action-setup@v2.2.4
with:
version: 7.11.0
version: 8.6.5
- name: Setup node@16
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 18
cache: "pnpm"
- name: Install dependencies
@@ -109,44 +109,9 @@ jobs:
tree -J -d -L 1 | jq -c '.[0].contents | map(.name | tostring) | map(select(. != "utils"))'
folders=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name | tostring) | map(select(. != "utils"))')
echo "folders=$folders" >> $GITHUB_OUTPUT
Generator:
name: :"Generator Test ${{matrix.language}}"
strategy:
matrix:
language:
- javascript
- typescript
os:
- ubuntu-latest
fail-fast: false
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PNPM
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 7.11.0
- name: Setup node@${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.NODE_VERSION }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
- name: Build
run: pnpm build
shell: bash
- name: Generate
run: |
mkdir test
cd test
pnpm blitz new . --language=${{matrix.language}}
Integration-Tests:
name: "Integration Test: ${{matrix.folder}} @ ${{matrix.os}} "
name: "Integration Test: ${{matrix.folder}} @ ${{ matrix.os }}"
needs: [find-integration-tests]
strategy:
matrix:
@@ -154,36 +119,44 @@ jobs:
os:
- ubuntu-latest
- windows-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- run: echo ${{matrix.folder}}
- name: Checkout
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
uses: actions/checkout@v3
- name: Setup PNPM
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
uses: pnpm/action-setup@v2.2.4
with:
version: 7.11.0
version: 8.6.5
- name: Setup node@${{ matrix.NODE_VERSION }}
- name: Setup node@18
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.NODE_VERSION }}
node-version: 18
cache: "pnpm"
- name: Install dependencies
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: pnpm install --frozen-lockfile
shell: bash
- name: Install playwright
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: |
pnpx playwright@1.28.0 install --with-deps
pnpx playwright@1.28.0 install --with-deps
shell: bash
- name: Build
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: pnpm build
shell: bash
- name: Test Packages
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: pnpm test -- --filter=./integration-tests/${{matrix.folder}}
shell: bash

View File

@@ -2,5 +2,5 @@
. "$(dirname "$0")/_/husky.sh"
pnpm manypkg check
pnpm lint
# pnpm lint
pnpm pretty-quick --staged

1
.npmrc
View File

@@ -1,4 +1,5 @@
save-exact=true
dedupe-peer-dependents=true
strict-peer-dependencies=false
public-hoist-pattern[]=secure-password

View File

@@ -6,7 +6,7 @@
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPfeAuTtA5ulPXYQ7wZ04Y+oOoDD9KZc9YOoOoDj9s4dwFzgXR6w1wIPoOvPWA9buAHEJ173o3gWiy3AnuBUHLEbgmYwvAk1/wuM8vAgexThzbwPDkx7/DHwVXfFOxP2GmsKd4Ab6zPeAyU8CI7AHFmH2BRCBPXAyk18GzUrqAXCTiR4ssyj0VFw/oCU8+e+RZ33AWz6KMaYbIIWxB+JSLs1bsbkeMN0AqakHvoku9oA2sAfqBvbAQdw0QArsgb25aYBUQT3QgT2gB+yBuqGcHij2UCqXDZACe2Anlw2QYg/QAOyBuoE98CL3DZDCuK4/rh/Q7oGL6U+TOvcNkJoijN8X1C48+T+g75eQDrAH/qmqAVJgDwyqaoAUe4AGYA/UDZX3QLUNkEIZPRCd5+6BahsgVUgPROwBTSijB7jpVAvGHriHvmw9wAZ4BpX1ABvgmakHtPcbRuwBTWAPULgAV9D/jKDY9YRvwvgEaurD44uQHvAol7qBW7WKluVtIHiUS7GyvA0s6CiXDnxrpQfsgbqBS7GKk/2jYHCrVlGyfxTMrVo0ALdq1Q3sgSKofh0M9oA61a+D2QM0AHugbmAPqClmSRjK2apVVQ8UsySsoK1aHdgDesCtWnUDeyCrIpeFg1u3sylyWTi3btMA7IG6gT2wuuK3hoE9sKrit4YVslWLPaAN7IG6ocKt2zmY2h4O9sDiTG0PZw/QANy6XTewBxZj9ogYVHy025LMHhEz9cBn0We6B0yfERReBLfhx0/R1YQHPx/QBPbA0VwcEwf2wNFcHBPHHjiem3MC2QPHcXdSaJjA+KfgTPQ8hhfjBzHC40mhlzJ+Xq9lK4a4PCs43AVaGTed5mZq+iOXZwWHi3AnOj2wFWNcnxYe7gTxLtBKHuamP/J+Wnh8a5irB7ZC5Yk9gPX1QuXC+usHWqGyhYvUYR0a7zboUOFCNVhnk0krZAOW7wFOvzXhom2xnEbIHizTA1wEYhWW6YFGyC6c1gOcfg9wfA80Qj7g8B7g9HuCww+haIR8wf49wOn3Cvv9k8tGyC/s7gFOv3fY3QONkH+v9MBWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
</a>
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-411-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-422-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE">
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
@@ -94,6 +94,11 @@ Your financial contributions help ensure Blitz continues to be developed and mai
<td><a aria-label="Boostry" href="https://boostry.co.jp/?utm_source=BlitzJS&utm_medium=sponsorship&utm_campaign=BlitzJS_Sponsorship_2021">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/boostry.svg" width="200px">
</a></td>
<td>
<a aria-label="Byteflow" href="https://byteflow.app/?ref=blitzjs">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/byteflow.png" width="70px">
</a>
</td>
</tr>
</table>
@@ -121,9 +126,11 @@ Your financial contributions help ensure Blitz continues to be developed and mai
<table>
<tr>
<td>
<a aria-label="Flightcontrol" href="https://www.flightcontrol.dev?ref=blitzjs">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/flightcontrol.png" width="400px">
</a>
</td>
</tr>
</table>
@@ -724,6 +731,21 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="https://maotoramm.com"><img src="https://avatars.githubusercontent.com/u/5174884?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maotora ᕙ(⇀‸↼‶)ᕗ</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=maotora" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=maotora" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vitaliemiron"><img src="https://avatars.githubusercontent.com/u/45145592?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vitalie</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Code">💻</a></td>
<td align="center"><a href="https://estevao.org"><img src="https://avatars.githubusercontent.com/u/19409687?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nelson Estevão</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/dbrxnds"><img src="https://avatars.githubusercontent.com/u/32268383?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/gjmoed"><img src="https://avatars.githubusercontent.com/u/4458993?v=4?s=100" width="100px;" alt=""/><br /><sub><b>G.J. Moed</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://ghken.com"><img src="https://avatars.githubusercontent.com/u/5304351?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tetsuya Fukuda</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/nerixim"><img src="https://avatars.githubusercontent.com/u/26106502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikita Kamaev</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nerixim" title="Documentation">📖</a></td>
<td align="center"><a href="https://webredone.com/"><img src="https://avatars.githubusercontent.com/u/11588823?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikola Ivanov</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nikola-wd" title="Documentation">📖</a></td>
<td align="center"><a href="jayu.dev"><img src="https://avatars.githubusercontent.com/u/11561585?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jakub Mazurek</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jayu" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=jayu" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/maciej-ka"><img src="https://avatars.githubusercontent.com/u/5403694?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maciej Kasprzyk</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=maciej-ka" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=maciej-ka" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/justinsmid"><img src="https://avatars.githubusercontent.com/u/34271675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Justin Smid</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=justinsmid" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=justinsmid" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/rodobre"><img src="https://avatars.githubusercontent.com/u/52138375?v=4?s=100" width="100px;" alt=""/><br /><sub><b>rodobre</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=rodobre" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=rodobre" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/Zamfi99"><img src="https://avatars.githubusercontent.com/u/19189337?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zamfira Costin-Andrei</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=Zamfi99" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=Zamfi99" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/potikhanovsergey"><img src="https://avatars.githubusercontent.com/u/71494201?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sergey</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=potikhanovsergey" title="Documentation">📖</a></td>
</tr>
</table>

View File

@@ -1,5 +1,131 @@
# next-blitz-auth
## 0.1.1-beta.12
### Patch Changes
- Updated dependencies [09e0c68db]
- @blitzjs/auth@2.0.0-beta.36
- blitz@2.0.0-beta.36
- @blitzjs/rpc@2.0.0-beta.36
- @blitzjs/next@2.0.0-beta.36
- @blitzjs/config@2.0.0-beta.36
## 0.1.1-beta.11
### Patch Changes
- Updated dependencies [cee2dec17]
- Updated dependencies [aec1bb076]
- Updated dependencies [b97366c42]
- Updated dependencies [3bcbad1a9]
- @blitzjs/auth@2.0.0-beta.35
- blitz@2.0.0-beta.35
- @blitzjs/next@2.0.0-beta.35
- @blitzjs/rpc@2.0.0-beta.35
- @blitzjs/config@2.0.0-beta.35
## 0.1.1-beta.10
### Patch Changes
- Updated dependencies [30fd61316]
- Updated dependencies [3ddb57072]
- Updated dependencies [fe8c937d2]
- blitz@2.0.0-beta.34
- @blitzjs/auth@2.0.0-beta.34
- @blitzjs/next@2.0.0-beta.34
- @blitzjs/rpc@2.0.0-beta.34
- @blitzjs/config@2.0.0-beta.34
## 0.1.1-beta.9
### Patch Changes
- Updated dependencies [19898a488]
- Updated dependencies [6811eab1a]
- Updated dependencies [022392c12]
- @blitzjs/rpc@2.0.0-beta.33
- blitz@2.0.0-beta.33
- @blitzjs/next@2.0.0-beta.33
- @blitzjs/auth@2.0.0-beta.33
- @blitzjs/config@2.0.0-beta.33
## 0.1.1-beta.8
### Patch Changes
- Updated dependencies [82649f341]
- Updated dependencies [8b01175b4]
- blitz@2.0.0-beta.32
- @blitzjs/next@2.0.0-beta.32
- @blitzjs/auth@2.0.0-beta.32
- @blitzjs/rpc@2.0.0-beta.32
- @blitzjs/config@2.0.0-beta.32
## 0.1.1-beta.7
### Patch Changes
- Updated dependencies [90f1741da]
- Updated dependencies [df3265b85]
- @blitzjs/auth@2.0.0-beta.31
- blitz@2.0.0-beta.31
- @blitzjs/rpc@2.0.0-beta.31
- @blitzjs/next@2.0.0-beta.31
- @blitzjs/config@2.0.0-beta.31
## 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
- Updated dependencies [b6b9a1c5a]
- Updated dependencies [61888d1a3]
- @blitzjs/auth@2.0.0-beta.29
- blitz@2.0.0-beta.29
- @blitzjs/rpc@2.0.0-beta.29
- @blitzjs/next@2.0.0-beta.29
- @blitzjs/config@2.0.0-beta.29
## 0.1.1-beta.4
### Patch Changes
- Updated dependencies [5166e5e03]
- Updated dependencies [2533caf48]
- Updated dependencies [c7ac86b85]
- Updated dependencies [1bb3a6556]
- @blitzjs/auth@2.0.0-beta.28
- @blitzjs/next@2.0.0-beta.28
- @blitzjs/rpc@2.0.0-beta.28
- blitz@2.0.0-beta.28
- @blitzjs/config@2.0.0-beta.28
## 0.1.1-beta.3
### Patch Changes
- Updated dependencies [eda14fa8a]
- Updated dependencies [3d004dc41]
- Updated dependencies [29c2b029a]
- @blitzjs/next@2.0.0-beta.27
- @blitzjs/rpc@2.0.0-beta.27
- @blitzjs/auth@2.0.0-beta.27
- blitz@2.0.0-beta.27
- @blitzjs/config@2.0.0-beta.27
## 0.1.1-beta.2
### Patch Changes

View File

@@ -1,4 +1,4 @@
import {useAuthenticatedBlitzContext} from "@blitzjs/auth"
import {useAuthenticatedBlitzContext} from "../../src/blitz-server"
export default async function RootLayout({children}: {children: React.ReactNode}) {
await useAuthenticatedBlitzContext({

View File

@@ -9,7 +9,6 @@ export default async function Home() {
redirectTo: "/auth/login",
})
const user = await invoke(getCurrentUser, null)
console.log("user", user)
return (
<div
style={{

View File

@@ -1,6 +1,6 @@
{
"name": "next-blitz-auth",
"version": "0.1.1-beta.2",
"version": "0.1.1-beta.12",
"private": true,
"scripts": {
"blitz:dev": "next dev",
@@ -9,17 +9,17 @@
"lint": "next lint"
},
"dependencies": {
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@blitzjs/rpc": "workspace:*",
"@blitzjs/auth": "2.0.0-beta.36",
"@blitzjs/config": "2.0.0-beta.36",
"@blitzjs/next": "2.0.0-beta.36",
"@blitzjs/rpc": "2.0.0-beta.36",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "^4.5.0",
"@tanstack/react-query": "4.0.10",
"blitz": "workspace:*",
"blitz": "2.0.0-beta.36",
"flatted": "3.2.7",
"next": "13.3.0",
"next": "13.5.2",
"prisma": "^4.5.0",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -13,7 +13,14 @@ const {api, getBlitzContext, useAuthenticatedBlitzContext, invoke} = setupBlitzS
storage: PrismaStorage(db),
isAuthorized: simpleRolesIsAuthorized,
}),
RpcServerPlugin({}),
RpcServerPlugin({
logging: {
disablelevel: "debug",
},
onInvokeError(error) {
console.log("onInvokeError", error)
},
}),
],
logger: BlitzLogger({}),
})

View File

@@ -23,15 +23,15 @@
]
},
"dependencies": {
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@blitzjs/rpc": "workspace:*",
"@blitzjs/auth": "2.0.0-beta.36",
"@blitzjs/config": "2.0.0-beta.36",
"@blitzjs/next": "2.0.0-beta.36",
"@blitzjs/rpc": "2.0.0-beta.36",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.26",
"next": "13.3.0",
"blitz": "2.0.0-beta.36",
"next": "13.5.2",
"openid-client": "5.2.1",
"prisma": "4.6.1",
"react": "18.2.0",

View File

@@ -2,10 +2,13 @@ const { withNextAuthAdapter } = require("@blitzjs/auth/next-auth")
const { withBlitz } = require("@blitzjs/next")
/**
* @type {import('@blitzjs/next').BlitzConfig}
* @type {import('next').NextConfig}
**/
const config = {
reactStrictMode: true,
blitz: {
resolversDynamicImport: true,
},
}
module.exports = withBlitz(withNextAuthAdapter(config))

View File

@@ -24,15 +24,15 @@
]
},
"dependencies": {
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@blitzjs/rpc": "workspace:*",
"@blitzjs/auth": "2.0.0-beta.36",
"@blitzjs/config": "2.0.0-beta.36",
"@blitzjs/next": "2.0.0-beta.36",
"@blitzjs/rpc": "2.0.0-beta.36",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.26",
"next": "13.3.0",
"blitz": "2.0.0-beta.36",
"next": "13.5.2",
"next-auth": "4.18.7",
"prisma": "4.6.1",
"react": "18.2.0",

View File

@@ -10,6 +10,7 @@ type SignupFormProps = {
export const SignupForm = (props: SignupFormProps) => {
const [signupMutation] = useMutation(signup)
return (
<div>
<h1>Create an Account</h1>

View File

@@ -1,5 +1,4 @@
import db from "db"
import { SecurePassword } from "@blitzjs/auth/secure-password"
import { Role } from "types"
export default async function signup(input, ctx) {

View File

@@ -1,9 +1,8 @@
import type { BlitzCliConfig } from "blitz"
import { setupBlitzServer } from "@blitzjs/next"
import { AuthServerPlugin, PrismaStorage } from "@blitzjs/auth"
import db from "db"
import { simpleRolesIsAuthorized } from "@blitzjs/auth"
import { BlitzLogger } from "blitz"
import { setupBlitzServer } from "@blitzjs/next"
import { AuthServerPlugin, PrismaStorage, simpleRolesIsAuthorized } from "@blitzjs/auth"
import db from "db"
export const cliConfig: BlitzCliConfig = {
customTemplates: "src/templates",
@@ -27,6 +26,9 @@ const { gSSP, gSP, api } = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
formatError: (error) => {
return new Error("Formatted error" + error.message)
},
logger: BlitzLogger({}),
})

View File

@@ -1,6 +1,6 @@
import { api } from "src/blitz-server"
import GithubProvider from "next-auth/providers/github"
import { NextAuthAdapter, BlitzNextAuthOptions } from "@blitzjs/auth/next-auth"
import { NextAuthAdapter } from "@blitzjs/auth/next-auth"
import db, { User } from "db"
import { Role } from "types"

View File

@@ -1,4 +1,16 @@
import { rpcHandler } from "@blitzjs/rpc"
import { api } from "src/blitz-server"
export default api(rpcHandler({ onError: console.log }))
export default api(
rpcHandler({
onError: console.log,
formatError: (error) => {
error.message = `FormatError handler: ${error.message}`
return error
},
// logging: {
// verbose: true,
// blockList: ["/getCurrentUser"],
// },
})
)

View File

@@ -38,13 +38,13 @@ const UserInfo = () => {
} else {
return (
<>
<Link href={Routes.SignupPage()} className={styles.button}>
<Link href={"/signup"} className={styles.button}>
<strong>Sign Up</strong>
</Link>
<Link href={Routes.LoginPage()} className={styles.loginButton}>
<Link href={"/login"} className={styles.loginButton}>
<strong>Login</strong>
</Link>
<Link href="/api/auth/github/login" passHref>
<Link href="/api/auth/github/login" passHref legacyBehavior>
<a className="button small">
<strong>Sign in with GitHub</strong>
</a>
@@ -99,7 +99,7 @@ const Home: BlitzPage = () => {
<div className={styles.code}>
<span>1</span>
<pre>
<code>blitz generate all project</code>
<code>blitz generate all project name:string</code>
</pre>
</div>

View File

@@ -16,17 +16,17 @@
"schema": "./db/schema.prisma"
},
"dependencies": {
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@blitzjs/rpc": "workspace:*",
"@blitzjs/auth": "2.0.0-beta.36",
"@blitzjs/config": "2.0.0-beta.36",
"@blitzjs/next": "2.0.0-beta.36",
"@blitzjs/rpc": "2.0.0-beta.36",
"@prisma/client": "4.6.1",
"@types/jest": "29.2.2",
"@types/passport-twitter": "1.0.37",
"blitz": "workspace:*",
"blitz": "2.0.0-beta.36",
"jest": "29.3.0",
"jest-environment-jsdom": "29.3.0",
"next": "13.3.0",
"next": "13.5.2",
"passport-mock-strategy": "2.0.0",
"passport-twitter": "1.0.4",
"prisma": "4.6.1",

View File

@@ -13,7 +13,6 @@ const {gSSP, gSP, api} = setupBlitzServer({
}),
],
logger: BlitzLogger({
colorizePrettyLogs: true,
prefix: ["[blitz]>>>>>"],
}),
})

BIN
assets/byteflow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 87 KiB

61
flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1687709756,
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1688221086,
"narHash": "sha256-cdW6qUL71cNWhHCpMPOJjlw0wzSRP0pVlRn2vqX/VVg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "cd99c2b3c9f160cd004318e0697f90bbd5960825",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

39
flake.nix Normal file
View File

@@ -0,0 +1,39 @@
{
description = "The Blitzjs Monorepo";
nixConfig.bash-prompt = "\[nix:blitz\]$ ";
inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs/nixpkgs-unstable";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs = {
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
formatter = pkgs.alejandra;
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs-18_x
];
shellHook = ''
mkdir -p $out/bin
${pkgs.nodejs-18_x}/bin/corepack enable --install-directory $out/bin
export PATH="$out/bin:$PATH"
'';
};
};
});
}

View File

@@ -17,16 +17,16 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.26",
"@blitzjs/config": "workspace:2.0.0-beta.26",
"@blitzjs/next": "workspace:2.0.0-beta.26",
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
"@blitzjs/auth": "2.0.0-beta.36",
"@blitzjs/config": "2.0.0-beta.36",
"@blitzjs/next": "2.0.0-beta.36",
"@blitzjs/rpc": "2.0.0-beta.36",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.26",
"blitz": "2.0.0-beta.36",
"delay": "5.0.0",
"next": "13.3.0",
"next": "13.5.2",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -1,6 +1,10 @@
import {Ctx} from "blitz"
import db from "../../db"
const getRand = () => Math.random().toString(36).substring(7)
export default async function login(_: any, ctx: Ctx) {
await ctx.session.$create({userId: 1, role: "USER"})
const user = await db.user.create({data: {email: `${getRand()}@example.com`}})
await ctx.session.$create({userId: user.id, role: "USER"})
return true
}

View File

@@ -0,0 +1,37 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"
function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
<div id="content">{result}</div>
<button
id="logout"
onClick={async () => {
await logoutMutation()
}}
>
logout
</button>
</div>
)
}
const Authenticate: BlitzPage = () => {
return (
<div id="page">
<Suspense fallback={"Loading..."}>
<Content />
</Suspense>
</div>
)
}
Authenticate.authenticate = {role: "USER", redirectTo: "/noauth-query"}
export default Authenticate

View File

@@ -0,0 +1,37 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"
function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
<div id="content">{result}</div>
<button
id="logout"
onClick={async () => {
await logoutMutation()
}}
>
logout
</button>
</div>
)
}
const Authenticate: BlitzPage = () => {
return (
<div id="page">
<Suspense fallback={"Loading..."}>
<Content />
</Suspense>
</div>
)
}
Authenticate.authenticate = {role: "ADMIN", redirectTo: "/noauth-query"}
export default Authenticate

View File

@@ -0,0 +1,37 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"
function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
<div id="content">{result}</div>
<button
id="logout"
onClick={async () => {
await logoutMutation()
}}
>
logout
</button>
</div>
)
}
const Authenticate: BlitzPage = () => {
return (
<div id="page">
<Suspense fallback={"Loading..."}>
<Content />
</Suspense>
</div>
)
}
Authenticate.authenticate = {role: "USER"}
export default Authenticate

View File

@@ -0,0 +1,37 @@
import {useMutation, useQuery} from "@blitzjs/rpc"
import {BlitzPage} from "@blitzjs/next"
import logout from "../mutations/logout"
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic"
import {Suspense} from "react"
function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [logoutMutation] = useMutation(logout)
return (
<div>
<div id="content">{result}</div>
<button
id="logout"
onClick={async () => {
await logoutMutation()
}}
>
logout
</button>
</div>
)
}
const Authenticate: BlitzPage = () => {
return (
<div id="page">
<Suspense fallback={"Loading..."}>
<Content />
</Suspense>
</div>
)
}
Authenticate.authenticate = {role: "ADMIN"}
export default Authenticate

View File

@@ -1,11 +1,11 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import {afterAll, beforeAll, describe, expect, it} from "vitest"
import {
killApp,
findPort,
runBlitzCommand,
blitzLaunchApp,
blitzBuild,
blitzLaunchApp,
blitzStart,
findPort,
killApp,
runBlitzCommand,
waitFor,
} from "../../utils/next-test-utils"
import webdriver from "../../utils/next-webdriver"
@@ -13,37 +13,10 @@ import webdriver from "../../utils/next-webdriver"
let app: any
let appPort: number
let mode: "dev" | "server" = "dev"
const runTests = () => {
describe("Auth", () => {
/* TODO - Add a non flaky Integration Test for custom plugin
describe("custom plugin", () => {
it("custom plugin - events", async () => {
const browser = await webdriver(appPort, "/custom-plugin")
let text = await browser.elementByCss("#page").text()
await waitFor(250)
text = await browser.elementByCss("#page").text()
expect(text).toBe("Custom plugin Session Created")
await waitFor(3000)
text = await browser.elementByCss("#page").text()
expect(text).toBe("Custom plugin RPC Error")
if (browser) {
await browser.close()
}
})
it("custom plugin - middleware", async () => {
const browser = await webdriver(appPort, "/custom-plugin")
await waitFor(100)
let text = await browser.elementByCss("#before-req").text()
expect(text).toBe("customHeaderValue")
await waitFor(2000)
text = await browser.elementByCss("#before-res").text()
expect(text).toBe("55")
if (browser) {
await browser.close()
}
})
})
*/
describe("unauthenticated", () => {
it("should render result for open query", async () => {
const browser = await webdriver(appPort, "/noauth-query")
@@ -58,7 +31,11 @@ const runTests = () => {
const browser = await webdriver(appPort, "/authenticated-query")
await browser.waitForElementByCss("#error")
let text = await browser.elementByCss("#error").text()
expect(text).toMatch(/AuthenticationError/)
if (mode === "server") {
expect(text).toMatch(/AuthenticationError/)
} else {
expect(text).toContain("Error")
}
if (browser) await browser.close()
})
@@ -70,6 +47,14 @@ const runTests = () => {
if (browser) await browser.close()
})
it("Page.authenticate = {role} should work ", async () => {
const browser = await webdriver(appPort, "/page-dot-authenticate-role")
await browser.waitForElementByCss("#error")
let text = await browser.elementByCss("#error").text()
expect(text).toMatch(/AuthenticationError/)
if (browser) await browser.close()
})
it("should render error for protected layout", async () => {
const browser = await webdriver(appPort, "/layout-authenticate")
await browser.waitForElementByCss("#error")
@@ -120,18 +105,36 @@ const runTests = () => {
await waitFor(200)
await browser.waitForElementByCss("#error")
text = await browser.elementByCss("#error").text()
expect(text).toMatch(/AuthenticationError/)
if (mode === "server") {
expect(text).toMatch(/AuthenticationError/)
} else {
expect(text).toContain("Error")
}
if (browser) await browser.close()
})
it("Page.authenticate = {redirect} should work ", async () => {
// Login
it("Page.authenticate = {role} should throw authentication error ", async () => {
let browser = await webdriver(appPort, "/login")
await waitFor(200)
await browser.elementByCss("#login").click()
await waitFor(200)
await browser.eval(`window.location = "/page-dot-authenticate-role"`)
await browser.waitForElementByCss("#error")
let text = await browser.elementByCss("#error").text()
expect(text).toMatch(/AuthenticationError/)
if (browser) await browser.close()
})
await browser.eval(`window.location = "/page-dot-authenticate-redirect"`)
it("Page.authenticate = {role: 'custom'} should work ", async () => {
let browser = await webdriver(appPort, "/page-dot-authenticate-role-working")
await browser.waitForElementByCss("#content")
let text = await browser.elementByCss("#content").text()
expect(text).toMatch(/authenticated-basic-result/)
if (browser) await browser.close()
})
it("Page.authenticate = {redirect} should work ", async () => {
let browser = await webdriver(appPort, "/page-dot-authenticate-redirect")
await browser.waitForElementByCss("#content")
let text = await browser.elementByCss("#content").text()
expect(text).toMatch(/authenticated-basic-result/)
@@ -142,14 +145,26 @@ const runTests = () => {
if (browser) await browser.close()
})
it("Layout.authenticate = {redirect} should work ", async () => {
// Login
it("Page.authenticate = {role: 'custom', redirect: 'url'} should work ", async () => {
let browser = await webdriver(appPort, "/login")
await waitFor(200)
await browser.elementByCss("#login").click()
await waitFor(200)
await browser.eval(`window.location = "/page-dot-authenticate-role-redirect"`)
await browser.waitForElementByCss("#content")
expect(await browser.url()).toMatch(/\/noauth-query/)
if (browser) await browser.close()
})
await browser.eval(`window.location = "/layout-authenticate-redirect"`)
it("Page.authenticate = {role: 'custom', redirect: 'url'} should stay ", async () => {
let browser = await webdriver(appPort, "/page-dot-authenticate-role-redirect-stay")
await browser.waitForElementByCss("#content")
expect(await browser.url()).toMatch(/\/page-dot-authenticate-role-redirect-stay/)
if (browser) await browser.close()
})
it("Layout.authenticate = {redirect} should work ", async () => {
let browser = await webdriver(appPort, "/layout-authenticate-redirect")
await browser.waitForElementByCss("#content")
let text = await browser.elementByCss("#content").text()
expect(text).toMatch(/authenticated-basic-result/)
@@ -262,6 +277,7 @@ const runTests = () => {
describe("Auth Tests", () => {
describe("dev mode", () => {
beforeAll(async () => {
mode = "dev"
try {
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
appPort = await findPort()
@@ -276,6 +292,7 @@ describe("Auth Tests", () => {
describe("server mode", () => {
beforeAll(async () => {
mode = "server"
try {
await runBlitzCommand(["prisma", "generate"])
await runBlitzCommand(["prisma", "migrate", "deploy"])

View File

@@ -17,13 +17,13 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.26",
"@blitzjs/config": "workspace:2.0.0-beta.26",
"@blitzjs/next": "workspace:2.0.0-beta.26",
"@blitzjs/auth": "2.0.0-beta.36",
"@blitzjs/config": "2.0.0-beta.36",
"@blitzjs/next": "2.0.0-beta.36",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.26",
"blitz": "2.0.0-beta.36",
"lowdb": "3.0.0",
"next": "13.3.0",
"next": "13.5.2",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -43,7 +43,7 @@ const runTests = (mode?: string) => {
const browser = await webdriver(appPort, "/authenticated-page")
let errorMsg = await browser.elementById(`error`).text()
expect(errorMsg).toMatch(/Error: You are not authenticated/)
if (browser) browser.close()
if (browser) void browser.close()
},
5000 * 60 * 2,
)

View File

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

View File

@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

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

View File

@@ -1,10 +1,16 @@
{
"extends": "@blitzjs/config/tsconfig.nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types", ".next/types/**/*.ts"],
"compilerOptions": {
"paths": {
"react": ["./node_modules/@types/react"]
}
},
"plugins": [
{
"name": "next"
}
],
"strictNullChecks": true
},
"exclude": ["node_modules"],
"baseUrl": "."

View File

@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

@@ -17,14 +17,14 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.26",
"@blitzjs/config": "workspace:2.0.0-beta.26",
"@blitzjs/next": "workspace:2.0.0-beta.26",
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
"@blitzjs/auth": "2.0.0-beta.36",
"@blitzjs/config": "2.0.0-beta.36",
"@blitzjs/next": "2.0.0-beta.36",
"@blitzjs/rpc": "2.0.0-beta.36",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.26",
"blitz": "2.0.0-beta.36",
"lowdb": "3.0.0",
"next": "13.3.0",
"next": "13.5.2",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -1,13 +1,6 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import {afterAll, beforeAll, describe, expect, it} from "vitest"
import waitPort from "wait-port"
import {
killApp,
findPort,
runBlitzCommand,
blitzLaunchApp,
blitzBuild,
blitzStart,
} from "../../utils/next-test-utils"
import {blitzLaunchApp, findPort, killApp, runBlitzCommand} from "../../utils/next-test-utils"
import webdriver from "../../utils/next-webdriver"
import fetch from "node-fetch"
@@ -43,7 +36,7 @@ const runTests = (mode?: string) => {
const browser = await webdriver(appPort, "/authenticated-client")
let errorMsg = await browser.elementById(`error`).text()
expect(errorMsg).toMatch(/Error: You are not authenticated/)
if (browser) browser.close()
if (browser) await browser.close()
},
5000 * 60 * 2,
)
@@ -55,7 +48,7 @@ const runTests = (mode?: string) => {
const browser = await webdriver(appPort, "/authenticated-server")
let errorMsg = await browser.elementById(`error`).text()
expect(errorMsg).toMatch(/Error: You are not authenticated/)
if (browser) browser.close()
if (browser) await browser.close()
},
5000 * 60 * 2,
)

View File

@@ -9,7 +9,8 @@
{
"name": "next"
}
]
],
"strictNullChecks": true
},
"exclude": ["node_modules"],
"baseUrl": "."

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ import {useQuery, useInfiniteQuery, BlitzRpcPlugin, QueryClientProvider} from "@
import React from "react"
import delay from "delay"
import {buildMutationRpc, buildQueryRpc, mockRouter, render} from "../../utils/blitz-test-utils"
import {RouterContext} from "next/dist/shared/lib/router-context"
import {RouterContext} from "@blitzjs/next"
beforeAll(() => {
globalThis.__BLITZ_SESSION_COOKIE_PREFIX = "qm-test-cookie-prefix"

View File

@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

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

View File

@@ -1,10 +1,16 @@
{
"extends": "@blitzjs/config/tsconfig.nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types", ".next/types/**/*.ts"],
"compilerOptions": {
"paths": {
"react": ["./node_modules/@types/react"]
}
},
"plugins": [
{
"name": "next"
}
],
"strictNullChecks": true
},
"exclude": ["node_modules"],
"baseUrl": "."

View File

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

View File

@@ -0,0 +1,12 @@
class ErrorWithStatusCode extends Error {
statusCode
constructor(message, statusCode) {
super(message)
this.statusCode = statusCode
}
}
export default async function getCustomStatusCodeFailure() {
throw new ErrorWithStatusCode("Error with custom status code for test", 418)
}

View File

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

View File

@@ -1,14 +1,13 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import fs from "fs-extra"
import {afterAll, beforeAll, describe, expect, it} from "vitest"
import {join} from "path"
import {
killApp,
findPort,
launchApp,
fetchViaHTTP,
findPort,
killApp,
launchApp,
nextBuild,
nextStart,
nextExport,
nextStart,
} from "../../utils/next-test-utils"
// jest.setTimeout(1000 * 60 * 2)

View File

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

View File

@@ -3,7 +3,7 @@ import {vi} from "vitest"
import {QueryClient} from "@tanstack/react-query"
import {BlitzRpcPlugin, QueryClientProvider} from "@blitzjs/rpc"
import {NextRouter} from "next/router"
import {RouterContext} from "next/dist/shared/lib/router-context"
import {RouterContext} from "@blitzjs/next"
import {render as defaultRender} from "@testing-library/react"
export const mockRouter: NextRouter = {
@@ -27,6 +27,7 @@ export const mockRouter: NextRouter = {
emit: vi.fn(),
},
isFallback: false,
forward: vi.fn(),
}
type DefaultParams = Parameters<typeof defaultRender>
@@ -74,7 +75,10 @@ const BlitzWrapper = ({plugins, children}) => {
)
}
export function render(ui: RenderUI, {wrapper, router, ...options}: RenderOptions = {}) {
export function render(
ui: RenderUI,
{wrapper, router, ...options}: RenderOptions = {},
): ReturnType<typeof defaultRender> {
if (!wrapper) {
wrapper = ({children}) => {
return <BlitzWrapper plugins={[BlitzRpcPlugin({})]}>{children}</BlitzWrapper>

View File

@@ -242,8 +242,8 @@ export function runBlitzCommandDev(argv, stdOut, opts: RunNextCommandDevOptions
function handleStdout(data) {
const message = data.toString()
const bootupMarkers = {
dev: /compiled .*successfully/i,
start: /started server/i,
dev: /Ready/i,
start: /Ready/i,
}
if (
(opts.bootupMarker && opts.bootupMarker.test(message)) ||
@@ -417,9 +417,10 @@ export function runNextCommandDev(argv, stdOut, opts: RunNextCommandDevOptions =
function handleStdout(data) {
const message = data.toString()
console.log(message)
const bootupMarkers = {
dev: /compiled .*successfully/i,
start: /started server/i,
dev: /Next.js/i,
start: /Next.js/i,
}
if (
(opts.bootupMarker && opts.bootupMarker.test(message)) ||
@@ -436,7 +437,7 @@ export function runNextCommandDev(argv, stdOut, opts: RunNextCommandDevOptions =
}
if (opts.stdout !== false) {
process.stdout.write(message)
process.stdout.write(message)
}
}

View File

@@ -3,8 +3,9 @@
"version": "0.0.0",
"private": true,
"devDependencies": {
"@blitzjs/config": "workspace: *",
"@blitzjs/rpc": "workspace: *",
"@blitzjs/config": "workspace:2.0.0-beta.36",
"@blitzjs/next": "workspace:2.0.0-beta.36",
"@blitzjs/rpc": "workspace:2.0.0-beta.36",
"@tanstack/react-query": "4.13.0",
"@testing-library/react": "13.4.0",
"@types/express": "4.17.13",

View File

@@ -13,7 +13,7 @@
"prepare": "husky install",
"build": "turbo run build",
"build:apps": "turbo run buildapp --concurrency=1",
"dev": "turbo run dev --no-cache --parallel",
"dev": "turbo run dev --filter='./packages/*'",
"lint": "turbo run lint",
"test": "turbo run test",
"clean": "turbo run clean && rm -rf node_modules",
@@ -29,20 +29,25 @@
"husky": "8.0.2",
"jsdom": "^19.0.0",
"lint-staged": "13.0.3",
"next": "13.3.0",
"next": "13.5.2",
"only-allow": "1.1.0",
"prettier": "^2.7.1",
"prettier-plugin-prisma": "4.4.0",
"pretty-quick": "3.1.3",
"turbo": "1.4.2",
"turbo": "1.10.9",
"vitest": "0.25.3",
"wait-on": "6.0.1"
},
"npmClient": "pnpm",
"packageManager": "pnpm@7.11.0",
"packageManager": "pnpm@8.6.6",
"manypkg": {
"ignoredRules": [
"EXTERNAL_MISMATCH"
]
},
"pnpm": {
"patchedDependencies": {
"next-auth@4.18.7": "patches/next-auth@4.18.7.patch"
}
}
}

View File

@@ -1,5 +1,119 @@
# @blitzjs/auth
## 2.0.0-beta.36
### Patch Changes
- 09e0c68db: Automatically authorize role with usage of `redirectAuthenticatedTo` in `useAuthenticatedBlitzContext` utility
- Updated dependencies [09e0c68db]
- blitz@2.0.0-beta.36
## 2.0.0-beta.35
### Patch Changes
- cee2dec17: Fix bug that did not allow `Page.authenicate = {role: "" }` to correctly work
- b97366c42: Remove unintended dependency on next-auth by removing it from the core build of @blitzjs/auth
⚠️ Breaking Change for current users of `withNextAuthAdapter`
Update your import in `next.config.js` in the following way
```diff
-const { withNextAuthAdapter } = require("@blitzjs/auth")
+const { withNextAuthAdapter } = require("@blitzjs/auth/next-auth")
```
- 3bcbad1a9: - Introduce Blitz RPC's logging system to the `invoke` function which is the recommended way to call resolvers in nextjs `app` directory's react server components.
- This refactor also removes the re-introduced dependency between `blitz-auth` and `blitz-rpc`, allowing independent usage of `blitz-rpc`
- Updated dependencies [cee2dec17]
- Updated dependencies [aec1bb076]
- Updated dependencies [b97366c42]
- Updated dependencies [3bcbad1a9]
- blitz@2.0.0-beta.35
## 2.0.0-beta.34
### Patch Changes
- 3ddb57072: ⚠️ Breaking Change:
Next.js version 13.5 or above is now required to use `@blitzjs/next`
Fix `Error: Cannot find module 'next/dist/shared/lib/router/utils/resolve-href'` by updating the location of next.js internal function.
- Updated dependencies [30fd61316]
- Updated dependencies [3ddb57072]
- Updated dependencies [fe8c937d2]
- blitz@2.0.0-beta.34
## 2.0.0-beta.33
### Patch Changes
- Updated dependencies [19898a488]
- Updated dependencies [6811eab1a]
- Updated dependencies [022392c12]
- blitz@2.0.0-beta.33
## 2.0.0-beta.32
### Patch Changes
- 8b01175b4: Updated `useAuthenticatedBlitzContext` to now return `AuthenticatedCtx`
- Updated dependencies [82649f341]
- blitz@2.0.0-beta.32
## 2.0.0-beta.31
### Patch Changes
- 90f1741da: blitz-auth: Support for Prisma v5
Internal: Make `handle` a required paramter while updating the `session` modal.
- Updated dependencies [90f1741da]
- Updated dependencies [df3265b85]
- blitz@2.0.0-beta.31
## 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
- b6b9a1c5a: Fix Next-Auth integration: `Unable to use next-auth with provider: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]`
- Updated dependencies [b6b9a1c5a]
- Updated dependencies [61888d1a3]
- blitz@2.0.0-beta.29
## 2.0.0-beta.28
### Minor Changes
- 1bb3a6556: Stop exporting `useAuthenticatedBlitzContext` from `@blitzjs/auth` this must be imported from `app/blitz-server.ts` file in order to work correctly
### Patch Changes
- 5166e5e03: (feat) upgrade tslog to v4.8.2
- Updated dependencies [5166e5e03]
- blitz@2.0.0-beta.28
## 2.0.0-beta.27
### Patch Changes
- 29c2b029a: Fix: Add missing entry to expose next-auth adapter in Blitz Auth
- blitz@2.0.0-beta.27
## 2.0.0-beta.26
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/auth",
"version": "2.0.0-beta.26",
"version": "2.0.0-beta.36",
"homepage": "https://blitzjs.com/",
"repository": {
"type": "git",
@@ -37,6 +37,7 @@
"cookie": "0.4.1",
"cookie-session": "2.0.0",
"debug": "4.3.3",
"find-up": "4.1.0",
"http": "0.0.1-security",
"jsonwebtoken": "9.0.0",
"nanoid": "3.2.0",
@@ -44,11 +45,12 @@
"openid-client": "5.2.1",
"passport": "0.6.0",
"path": "0.12.7",
"resolve-from": "5.0.0",
"supports-color": "8.1.1",
"url": "0.11.0"
},
"peerDependencies": {
"blitz": "2.0.0-beta.26",
"blitz": "2.0.0-beta.36",
"next": "*",
"next-auth": "*",
"secure-password": "4.0.0"
@@ -65,7 +67,7 @@
}
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.26",
"@blitzjs/config": "2.0.0-beta.36",
"@testing-library/react": "13.4.0",
"@testing-library/react-hooks": "8.0.1",
"@types/cookie": "0.4.1",
@@ -73,8 +75,8 @@
"@types/jsonwebtoken": "8.5.8",
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"blitz": "2.0.0-beta.26",
"next": "13.3.0",
"blitz": "2.0.0-beta.36",
"next": "13.5.2",
"next-auth": "4.18.7",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -310,12 +310,12 @@ function withBlitzAuthPlugin<TProps = any>(Page: ComponentType<TProps> | BlitzPa
}, [])
let {authenticate, redirectAuthenticatedTo} = getAuthValues(Page, props)
useAuthorizeIf(
authenticate === true,
!!authenticate &&
((typeof authenticate === "object" && authenticate.redirectTo === undefined) ||
authenticate === true),
!authenticate ? undefined : typeof authenticate === "object" ? authenticate.role : undefined,
)
if (typeof window !== "undefined") {
const publicData = getPublicDataStore().getData()

View File

@@ -1,8 +1,10 @@
import {AuthPluginOptions} from "./server"
import {SessionConfigMethods} from "./shared"
import type {Ctx} from "blitz"
import type {AuthPluginOptions} from "./server"
import type {SessionConfigMethods} from "./shared"
declare global {
var sessionConfig: AuthPluginOptions & SessionConfigMethods
var __BLITZ_SESSION_COOKIE_PREFIX: string | undefined
var __BLITZ_SUSPENSE_ENABLED: boolean
var __BLITZ_GET_RSC_CONTEXT: () => Promise<Ctx>
}

View File

@@ -1,3 +1,2 @@
export * from "./next-auth/adapter"
export * from "./next-auth/types"
export * from "./next-auth/webpack"

View File

@@ -13,6 +13,8 @@ import {
} from "blitz"
import {isLocalhost, SessionContext} from "../../../index-server"
export {withNextAuthAdapter} from "./webpack"
// next-auth internals
import {toInternalRequest, toResponse} from "./internals/utils/web"
import {getBody, getURL, setHeaders} from "./internals/utils/node"
@@ -27,7 +29,9 @@ import type {
} from "./types"
import {Provider} from "next-auth/providers"
export {withNextAuthAdapter} from "./webpack"
import {init} from "next-auth/core/init"
import getAuthorizationUrl from "next-auth/core/lib/oauth/authorization-url"
import oAuthCallback from "next-auth/core/lib/oauth/callback"
const INTERNAL_REDIRECT_URL_KEY = "_redirectUrl"
@@ -102,7 +106,6 @@ export function NextAuthAdapter<P extends Provider[]>(
if (providerId?.includes("?")) {
providerId = providerId.split("?")[0]
}
const {init} = await import("next-auth/core/init").then((m) => m)
const {options, cookies} = await init({
// @ts-ignore
url: new URL(
@@ -158,9 +161,6 @@ async function AuthHandler<P extends Provider[]>(
if (action === "login") {
middleware.push(async (req, res, next) => {
try {
const getAuthorizationUrl = await import("next-auth/core/lib/oauth/authorization-url").then(
(m) => m.default,
)
const _signin = await getAuthorizationUrl({options: options, query: req.query})
if (_signin.cookies) cookies.push(..._signin.cookies)
const session = res.blitzCtx.session as SessionContext
@@ -191,9 +191,6 @@ async function AuthHandler<P extends Provider[]>(
middleware.push(
// eslint-disable-next-line no-shadow
connectMiddleware(async (req, res, next) => {
const oAuthCallback = await import("next-auth/core/lib/oauth/callback").then(
(m) => m.default,
)
try {
const {profile, account, OAuthProfile} = await oAuthCallback({
query: internalRequest.query,

View File

@@ -1,15 +1,30 @@
//@ts-nocheck
import path from "path"
export function withNextAuthAdapter(nextConfig) {
const config = Object.assign({}, nextConfig)
config.webpack = (config) => {
//add a required resolve alias
config.resolve.alias["next-auth/core/lib/oauth/callback"] =
process.cwd() + "/node_modules/next-auth/core/lib/oauth/callback.js"
config.resolve.alias["next-auth/core/lib/oauth/authorization-url"] =
process.cwd() + "/node_modules/next-auth/core/lib/oauth/authorization-url.js"
config.resolve.alias["next-auth/core/init"] =
process.cwd() + "/node_modules/next-auth/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
}
return config
}

View File

@@ -1,4 +1,4 @@
import {BlitzServerPlugin, RequestMiddleware, Ctx, createServerPlugin} from "blitz"
import {RequestMiddleware, Ctx, createServerPlugin} from "blitz"
import {assert} from "blitz"
import {IncomingMessage, ServerResponse} from "http"
import {PublicData, SessionModel, SessionConfigMethods} from "../shared/types"
@@ -31,7 +31,7 @@ interface PrismaClientWithSession {
}): Promise<SessionModel>
update(args: {
data: Partial<SessionModel>
where: {handle?: SessionModel["handle"]}
where: {handle: SessionModel["handle"]}
}): Promise<SessionModel>
delete(args: {where: {handle?: SessionModel["handle"]}}): Promise<SessionModel>
}
@@ -125,6 +125,9 @@ export const AuthServerPlugin = createServerPlugin((options: AuthPluginOptions)
}
return blitzSessionMiddleware
}
if (!globalThis.__BLITZ_GET_RSC_CONTEXT) {
globalThis.__BLITZ_GET_RSC_CONTEXT = getBlitzContext
}
return {
requestMiddlewares: [authPluginSessionMiddleware()],
exports: () => ({

View File

@@ -15,6 +15,7 @@ import {
log,
baseLogger,
chalk,
AuthenticatedCtx,
} from "blitz"
import {
EmptyPublicData,
@@ -219,8 +220,8 @@ export async function useAuthenticatedBlitzContext({
redirectTo?: string | RouteUrlObject
redirectAuthenticatedTo?: string | RouteUrlObject | ((ctx: Ctx) => string | RouteUrlObject)
role?: string | string[]
}): Promise<void> {
const log = baseLogger().getChildLogger()
}): Promise<AuthenticatedCtx> {
const log = baseLogger().getSubLogger({name: "useAuthenticatedBlitzContext"})
const customChalk = new chalk.Instance({
level: log.settings.type === "json" ? 0 : chalk.level,
})
@@ -242,8 +243,17 @@ export async function useAuthenticatedBlitzContext({
? redirectAuthenticatedTo
: formatWithValidation(redirectAuthenticatedTo)
debug("[useAuthenticatedBlitzContext] Redirecting to", redirectUrl)
log.info("Authentication Redirect: " + customChalk.dim("(Authenticated)"), redirectUrl)
redirect(redirectUrl)
if (role) {
try {
ctx.session.$authorize(role)
} catch (e) {
log.info("Authentication Redirect: " + customChalk.dim(`Role ${role}`), redirectTo)
redirect(redirectUrl)
}
} else {
log.info("Authentication Redirect: " + customChalk.dim("(Authenticated)"), redirectUrl)
redirect(redirectUrl)
}
}
if (redirectTo && role) {
debug("[useAuthenticatedBlitzContext] redirectTo and role are both defined.")
@@ -268,6 +278,7 @@ export async function useAuthenticatedBlitzContext({
redirect(redirectTo)
}
}
return ctx as AuthenticatedCtx
}
const makeProxyToPublicData = <T extends SessionContextClass>(ctxClass: T): T => {

View File

@@ -1,4 +1,16 @@
export * from "./auth-sessions"
export * from "./auth-utils"
export * from "./auth-plugin"
export * from "./adapters"
export {
SessionContextClass,
getAllSessionHandlesForUser,
getCookieParser,
getSession,
isLocalhost,
setPublicDataForUser,
setCookie,
simpleRolesIsAuthorized,
getBlitzContext,
} from "./auth-sessions"
export type {AnonymousSessionPayload, SimpleRolesIsAuthorized} from "./auth-sessions"

View File

@@ -82,7 +82,7 @@ declare module "blitz" {
export interface Ctx {
session: SessionContext
}
export interface AuthenticatedMiddlewareCtx extends Omit<Ctx, "session"> {
export interface AuthenticatedCtx extends Omit<Ctx, "session"> {
session: AuthenticatedSessionContext
}
}

Some files were not shown because too many files have changed in this diff Show More