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

Compare commits

...

31 Commits

Author SHA1 Message Date
github-actions[bot]
f7735d59a3 Version Packages (beta) (#4262)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-01-02 22:55:50 +05:30
Siddharth Suresh
6d5f9efe14 new blitz app starter (#4146)
* new blitz app starter

* tanstack form first time working

* complete app template

* re-arrange generator folders

* add app router as recomended

* 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.

* fix starter with tanstack form

* make changes to the generator

* mske final changes

* pnpm lock fix

* more changes

* 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

* move app -> `src/app`

* move from auth -> (auth) directory structure

* review 1 fixes

* missing change from auth -> (auth) change

* review 2: more fixes and match old behaviour

* pnpm lock fix

* add new pages to the `pathsToMove` array

* remove submodule

* remove changelog from the template

* fix name of .env

* match readme

* march prisma schema

* match package.json

* match blitz-client and blitz-server files

* remove vercel logo

* remove `next13`

* upgrade next and add husky

* fix build error

* Create poor-bikes-wait.md

* Revert "remove `next13`"

This reverts commit c0d7f54ab1.

* remove next13

* re-add next 13 that exists in main

* Apply suggestions from code review

* pnpm lock

* improvements to the template

* fix location of imports in `reset-password` page

* Update packages/blitz/src/cli/commands/new.ts

Co-authored-by: Tobias <tobias@fixmycity.de>

* Update packages/generator/templates/app/src/pages/api/rpc/blitzrpcroute.ts

Co-authored-by: Tobias <tobias@fixmycity.de>

* fix auth -> (auth)

* Update packages/generator/templates/app/src/app/layout.tsx

Co-authored-by: Tobias <tobias@fixmycity.de>

* Apply suggestions from code review

Co-authored-by: Tobias <tobias@fixmycity.de>

* abstact forms as client compoennts and pages as rscs

* re-add proper singup mutation

* remove console.log

* fix additonal forms

* pnpm lock fix

* fix missing ,

* Add project package manager to postInstallSteps

* add husky

* move to devDeps

* add preview email

* remove extra components folder

* add 800px as maximum of body size

* remove auth from reset-password url

* fix non-existant compoennts

* pnpm

* fix favicon

* package.json fixes

* revert to `latest`

* move to `devDeps`

* add display names

* make it a template

* new route generator

* fidnally got it working

* add `isAppDir` check

* should be the final changes

* fix

* fix import error

* revert

* make zod optional when needed

* fix tests

* fix nullable issue

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

* new folder structure

---------

Co-authored-by: Tobias <tobias@fixmycity.de>
2024-01-02 22:52:14 +05:30
Siddharth Suresh
b84c5bedbd Next 14 Compatibility (#4263)
* upgrade to next 14

* use default react import

* use `next/compat/router`

* set baseurl for next13 app

* get it working

* fix Error Component

* fix floating promisis

* Create modern-cups-cheat.md

* fix type of error boundary

* get react query working again

* remove experimental

* remove broken test since next export is removed

* fix qm integration test

* fix mismatch of cookie names in client and server

* fix `auth-with-rpc`

* fix unit tests

* fix snapshot

* remove `@tanstack/query-core` dep from `@blitzjs/rpc`

* Update .changeset/modern-cups-cheat.md

* fix: lockfile

* regression: re-export react query client utilites

* Update .changeset/modern-cups-cheat.md

* do not export `withRouter`

* revert change to `BlitzProvider`

* remove unnecessary next types
2024-01-02 17:05:41 +00:00
Blitz.js Bot
f80cd3dba9 (meta) added @papsavas as contributor 2023-12-20 13:09:22 -05:00
Savvas Papageorgiadis
e5cd2c8622 chore(rpcHandler): onError ctx (#4259)
* chore(rpcHandler): onError ctx

* chore: add changeset

* Update .changeset/rare-squids-brake.md

---------

Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
2023-12-20 18:09:17 +00:00
Siddharth Suresh
86e8eb7c8c Add helpful error message when RPC resolvers have the same path (#4261)
* add helpful error message when resolvers have the same path

* Create cyan-rings-play.md

* Apply suggestions from code review
2023-12-13 17:17:04 +00:00
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
326 changed files with 6738 additions and 1441 deletions

View File

@@ -3975,6 +3975,45 @@
"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"
]
},
{
"login": "papsavas",
"name": "Savvas Papageorgiadis",
"avatar_url": "https://avatars.githubusercontent.com/u/50584606?v=4",
"profile": "https://github.com/papsavas",
"contributions": [
"doc",
"code"
]
}
],
"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,6 @@
---
"@blitzjs/next": patch
"blitz": patch
---
blitz-next: Fix `next/head` used in app directory warning

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Add helpful error message when RPC resolvers have the same path

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,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,9 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
"blitz": patch
---
Next 14 Compatibility

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,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 @@
---
"@blitzjs/generator": patch
---
new blitz app starter

View File

@@ -53,6 +53,7 @@
"changesets": [
"afraid-dancers-juggle",
"afraid-ears-repair",
"afraid-ligers-build",
"big-boats-lay",
"big-phones-bow",
"big-turtles-tease",
@@ -72,6 +73,7 @@
"calm-tomatoes-drive",
"chatty-fireants-leave",
"chatty-gifts-whisper",
"chatty-scissors-jump",
"chilled-carrots-own",
"chilly-candles-care",
"chilly-jeans-fix",
@@ -91,6 +93,7 @@
"curvy-drinks-perform",
"cyan-bulldogs-heal",
"cyan-cars-greet",
"cyan-rings-play",
"dirty-monkeys-greet",
"dirty-planets-chew",
"dull-rings-arrive",
@@ -149,6 +152,7 @@
"great-terms-rescue",
"green-papayas-do",
"green-pillows-hammer",
"green-years-behave",
"happy-bees-lick",
"happy-hotels-visit",
"happy-paws-join",
@@ -162,6 +166,7 @@
"honest-comics-vanish",
"hot-cups-rhyme",
"hot-drinks-approve",
"hot-knives-vanish",
"hungry-baboons-swim",
"hungry-pens-collect",
"itchy-cups-double",
@@ -179,6 +184,7 @@
"lemon-teachers-jam",
"light-donkeys-double",
"light-squids-draw",
"little-cycles-hang",
"little-pears-ring",
"long-bees-hope",
"long-dancers-jog",
@@ -188,23 +194,30 @@
"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-cups-cheat",
"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",
@@ -229,6 +242,7 @@
"plenty-gifts-provide",
"plenty-kiwis-greet",
"polite-lizards-love",
"poor-bikes-wait",
"poor-crabs-drum",
"poor-peas-lick",
"poor-penguins-look",
@@ -236,15 +250,18 @@
"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",
"quiet-pans-hunt",
"quiet-sloths-rule",
"rare-crews-sleep",
"rare-squids-brake",
"red-badgers-retire",
"red-gorillas-marry",
"rich-chairs-invent",
@@ -253,6 +270,7 @@
"rotten-rocks-remember",
"rude-trainers-visit",
"serious-mugs-leave",
"shaggy-boxes-exercise",
"shaggy-carpets-brake",
"sharp-falcons-begin",
"sharp-olives-sip",

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,5 @@
---
"@blitzjs/rpc": minor
---
expose `ctx` to `rpcHandler` error callbacks in [[...blitz]].ts files

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

@@ -6,6 +6,7 @@
### Now we can configure Blitz RPC in the following way,
In your `[[...blitz]].ts` api file you can see the following settings
```ts
logging?: {
/**
@@ -29,6 +30,7 @@ logging?: {
disablelevel?: "debug" | "info"
}
```
```ts
import { rpcHandler } from "@blitzjs/rpc"
import { api } from "src/blitz-server"
@@ -48,6 +50,7 @@ export default api(
```
Example:
```ts
export default api(
rpcHandler({
@@ -65,4 +68,3 @@ export default api(
```
This is enable verbose blitz rpc logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList`

View File

@@ -23,7 +23,7 @@ jobs:
- 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
@@ -44,7 +44,7 @@ jobs:
- 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,7 +62,7 @@ jobs:
- windows-latest
fail-fast: false
env:
NODE_VERSION: 16
NODE_VERSION: 18
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -75,7 +75,7 @@ jobs:
- name: Setup node@16
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 18
cache: "pnpm"
- name: Install dependencies
@@ -111,7 +111,7 @@ jobs:
echo "folders=$folders" >> $GITHUB_OUTPUT
Integration-Tests:
name: "Integration Test: ${{matrix.folder}} @ ${{ matrix.os }} "
name: "Integration Test: ${{matrix.folder}} @ ${{ matrix.os }}"
needs: [find-integration-tests]
strategy:
matrix:
@@ -124,32 +124,39 @@ jobs:
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
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
uses: pnpm/action-setup@v2.2.4
with:
version: 8.6.5
- name: Setup node@18
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
uses: actions/setup-node@v2
with:
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
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

@@ -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-419-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-423-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">
@@ -96,7 +96,7 @@ Your financial contributions help ensure Blitz continues to be developed and mai
</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">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/byteflow.png" width="70px">
</a>
</td>
</tr>
@@ -126,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>
@@ -739,6 +741,12 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<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>
<td align="center"><a href="https://github.com/papsavas"><img src="https://avatars.githubusercontent.com/u/50584606?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Savvas Papageorgiadis</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=papsavas" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=papsavas" title="Code">💻</a></td>
</tr>
</table>

View File

@@ -1,5 +1,69 @@
# next-blitz-auth
## 0.1.1-beta.13
### Patch Changes
- Updated dependencies [86e8eb7c8]
- Updated dependencies [b84c5bedb]
- Updated dependencies [e5cd2c862]
- @blitzjs/rpc@2.0.0-beta.37
- blitz@2.0.0-beta.37
- @blitzjs/auth@2.0.0-beta.37
- @blitzjs/next@2.0.0-beta.37
- @blitzjs/config@2.0.0-beta.37
## 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

View File

@@ -1,11 +1,6 @@
const {withBlitz} = require("@blitzjs/next")
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
serverComponentsExternalPackages: ["@prisma/client", "prisma"],
},
}
const nextConfig = {}
module.exports = withBlitz(nextConfig)

View File

@@ -1,6 +1,6 @@
{
"name": "next-blitz-auth",
"version": "0.1.1-beta.8",
"version": "0.1.1-beta.13",
"private": true,
"scripts": {
"blitz:dev": "next dev",
@@ -8,18 +8,21 @@
"blitz:start": "next start",
"lint": "next lint"
},
"prisma": {
"schema": "prisma/schema.prisma"
},
"dependencies": {
"@blitzjs/auth": "2.0.0-beta.32",
"@blitzjs/config": "2.0.0-beta.32",
"@blitzjs/next": "2.0.0-beta.32",
"@blitzjs/rpc": "2.0.0-beta.32",
"@blitzjs/auth": "2.0.0-beta.37",
"@blitzjs/config": "2.0.0-beta.37",
"@blitzjs/next": "2.0.0-beta.37",
"@blitzjs/rpc": "2.0.0-beta.37",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "^4.5.0",
"@tanstack/react-query": "4.0.10",
"blitz": "2.0.0-beta.32",
"blitz": "2.0.0-beta.37",
"flatted": "3.2.7",
"next": "13.3.0",
"next": "14.0.4",
"prisma": "^4.5.0",
"react": "18.2.0",
"react-dom": "18.2.0",

Binary file not shown.

View File

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

View File

@@ -1,6 +1,6 @@
"use client"
import {LoginForm} from "../../../src/auth/components/LoginForm"
import {LoginForm} from "../../../auth/components/LoginForm"
import {useRouter} from "next/navigation"
import {useSearchParams} from "next/navigation"

View File

@@ -1,7 +1,7 @@
"use client"
import {useRouter} from "next/navigation"
import SignupForm from "../../../src/auth/components/SignupForm"
import SignupForm from "../../../auth/components/SignupForm"
const SignUp = () => {
const router = useRouter()

View File

@@ -1,5 +1,5 @@
import "src/styles/globals.css"
import {BlitzProvider} from "../src/blitz-client"
import {BlitzProvider} from "../blitz-client"
import styles from "src/styles/Home.module.css"
export default function RootLayout({children}: {children: React.ReactNode}) {

View File

@@ -1,15 +1,14 @@
import Link from "next/link"
import styles from "src/styles/Home.module.css"
import Test from "./react-query"
import {invoke, useAuthenticatedBlitzContext} from "../src/blitz-server"
import getCurrentUser from "../src/users/queries/getCurrentUser"
import {invoke, useAuthenticatedBlitzContext} from "../blitz-server"
import getCurrentUser from "../users/queries/getCurrentUser"
export default async function Home() {
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
})
const user = await invoke(getCurrentUser, null)
console.log("user", user)
return (
<div
style={{

View File

@@ -1,8 +1,8 @@
"use client"
import {useQuery, useMutation} from "@blitzjs/rpc"
import logout from "../src/auth/mutations/logout"
import getCurrentUser from "../src/users/queries/getCurrentUser"
import logout from "../auth/mutations/logout"
import getCurrentUser from "../users/queries/getCurrentUser"
import {useTransition} from "react"
import {useRouter} from "next/navigation"

View File

@@ -1,11 +1,10 @@
import db from "../../../prisma"
// import {SecurePassword} from "@blitzjs/auth"
import {SecurePassword} from "@blitzjs/auth/secure-password"
export default async function signup(input: {password: string; email: string}, ctx: any) {
const blitzContext = ctx
// const hashedPassword = await SecurePassword.hash((input.password as string) || "test-password")
const hashedPassword = (input.password as string) || "test-password"
const email = (input.email as string) || "test" + Math.random() + "@test.com"
const hashedPassword = await SecurePassword.hash((input.password as string) || "test-password")
const email = input.email
const user = await db.user.create({
data: {email, hashedPassword},
})

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

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

View File

@@ -14,6 +14,7 @@
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"plugins": [
{
"name": "next"

View File

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

View File

@@ -1,4 +1,4 @@
import { rpcHandler } from "@blitzjs/rpc"
import { api } from "src/blitz-server"
export default api(rpcHandler({ onError: console.log }))
export default api(rpcHandler({ onError: (error, ctx) => console.log(error) }))

View File

@@ -1,4 +1,4 @@
const { withNextAuthAdapter } = require("@blitzjs/auth")
const { withNextAuthAdapter } = require("@blitzjs/auth/next-auth")
const { withBlitz } = require("@blitzjs/next")
/**

View File

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

View File

@@ -1,5 +1,6 @@
import { api } from "src/blitz-server"
import GithubProvider from "next-auth/providers/github"
import EmailProvider from "next-auth/providers/email"
import { NextAuthAdapter, BlitzNextAuthOptions } from "@blitzjs/auth/next-auth"
import db, { User } from "db"
import { Role } from "types"
@@ -10,6 +11,10 @@ const providers = [
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
}),
EmailProvider({
from: process.env.GITHUB_CLIENT_ID as string,
server: process.env.GITHUB_CLIENT_SECRET as string,
}),
]
export default api(

View File

@@ -3,8 +3,8 @@ import { api } from "src/blitz-server"
export default api(
rpcHandler({
onError: console.log,
formatError: (error) => {
onError: (error, ctx) => console.log(error),
formatError: (error, ctx) => {
error.message = `FormatError handler: ${error.message}`
return error
},

View File

@@ -1,4 +1,3 @@
import { useEffect, useState } from "react"
import Layout from "src/core/layouts/Layout"
import { LabeledTextField } from "src/core/components/LabeledTextField"
import { Form, FORM_ERROR } from "src/core/components/Form"

View File

@@ -38,10 +38,10 @@ const UserInfo = () => {
} else {
return (
<>
<Link href={"/signup"} className={styles.button}>
<Link href={"/auth/signup"} className={styles.button}>
<strong>Sign Up</strong>
</Link>
<Link href={"/login"} className={styles.loginButton}>
<Link href={"/auth/login"} className={styles.loginButton}>
<strong>Login</strong>
</Link>
<Link href="/api/auth/github/login" passHref legacyBehavior>

View File

@@ -1,32 +0,0 @@
/**
* @vitest-environment jsdom
*/
import { expect, vi, test } from "vitest"
import { render } from "test/utils"
import Home from "../src/pages/index"
vi.mock("public/logo.png", () => ({
default: { src: "/logo.png" },
}))
test.skip("renders blitz documentation link", () => {
// This is an example of how to ensure a specific item is in the document
// But it's disabled by default (by test.skip) so the test doesn't fail
// when you remove the default content from the page
// This is an example on how to mock api hooks when testing
vi.mock("src/users/hooks/useCurrentUser", () => ({
useCurrentUser: () => ({
id: 1,
name: "User",
email: "user@email.com",
role: "user",
}),
}))
const { getByText } = render(<Home />)
const linkElement = getByText(/Blitz Docs/i)
expect(linkElement).toBeInTheDocument()
})

View File

@@ -1,3 +0,0 @@
import "@testing-library/jest-dom"
export {}

View File

@@ -1,106 +0,0 @@
import { vi } from "vitest"
import { render as defaultRender } from "@testing-library/react"
import { renderHook as defaultRenderHook } from "@testing-library/react-hooks"
import { NextRouter } from "next/router"
import { BlitzProvider, RouterContext } from "@blitzjs/next"
import { QueryClient } from "@blitzjs/rpc"
export * from "@testing-library/react"
// --------------------------------------------------------------------------------
// This file customizes the render() and renderHook() test functions provided
// by React testing library. It adds a router context wrapper with a mocked router.
//
// You should always import `render` and `renderHook` from this file
//
// This is the place to add any other context providers you need while testing.
// --------------------------------------------------------------------------------
// --------------------------------------------------
// render()
// --------------------------------------------------
// Override the default test render with our own
//
// You can override the router mock like this:
//
// const { baseElement } = render(<MyComponent />, {
// router: { pathname: '/my-custom-pathname' },
// });
// --------------------------------------------------
const queryClient = new QueryClient()
export function render(
ui: RenderUI,
{ wrapper, router, dehydratedState, ...options }: RenderOptions = {}
) {
if (!wrapper) {
// Add a default context wrapper if one isn't supplied from the test
wrapper = ({ children }: { children: React.ReactNode }) => (
<BlitzProvider dehydratedState={dehydratedState} client={queryClient}>
<RouterContext.Provider value={{ ...mockRouter, ...router }}>
{children}
</RouterContext.Provider>
</BlitzProvider>
)
}
return defaultRender(ui, { wrapper, ...options })
}
// --------------------------------------------------
// renderHook()
// --------------------------------------------------
// Override the default test renderHook with our own
//
// You can override the router mock like this:
//
// const result = renderHook(() => myHook(), {
// router: { pathname: '/my-custom-pathname' },
// });
// --------------------------------------------------
export function renderHook(
hook: RenderHook,
{ wrapper, router, dehydratedState, ...options }: RenderOptions = {}
) {
if (!wrapper) {
// Add a default context wrapper if one isn't supplied from the test
wrapper = ({ children }: { children: React.ReactNode }) => (
<BlitzProvider dehydratedState={dehydratedState} client={queryClient}>
<RouterContext.Provider value={{ ...mockRouter, ...router }}>
{children}
</RouterContext.Provider>
</BlitzProvider>
)
}
return defaultRenderHook(hook, { wrapper, ...options })
}
export const mockRouter: NextRouter = {
basePath: "",
pathname: "/",
route: "/",
asPath: "/",
query: {},
isReady: true,
isLocaleDomain: false,
forward: vi.fn(),
prefetch: vi.fn(),
isPreview: false,
push: vi.fn(),
replace: vi.fn(),
reload: vi.fn(),
back: vi.fn(),
beforePopState: vi.fn(),
events: {
on: vi.fn(),
off: vi.fn(),
emit: vi.fn(),
},
isFallback: false,
}
type DefaultParams = Parameters<typeof defaultRender>
type RenderUI = DefaultParams[0]
type RenderOptions = DefaultParams[1] & { router?: Partial<NextRouter>; dehydratedState?: unknown }
type DefaultHookParams = Parameters<typeof defaultRenderHook>
type RenderHook = DefaultHookParams[0]

View File

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

View File

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "src/blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

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

View File

@@ -17,16 +17,16 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "2.0.0-beta.32",
"@blitzjs/config": "2.0.0-beta.32",
"@blitzjs/next": "2.0.0-beta.32",
"@blitzjs/rpc": "2.0.0-beta.32",
"@blitzjs/auth": "2.0.0-beta.37",
"@blitzjs/config": "2.0.0-beta.37",
"@blitzjs/next": "2.0.0-beta.37",
"@blitzjs/rpc": "2.0.0-beta.37",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "2.0.0-beta.32",
"blitz": "2.0.0-beta.37",
"delay": "5.0.0",
"next": "13.3.0",
"next": "14.0.4",
"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

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

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

@@ -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": "2.0.0-beta.32",
"@blitzjs/config": "2.0.0-beta.32",
"@blitzjs/next": "2.0.0-beta.32",
"@blitzjs/auth": "2.0.0-beta.37",
"@blitzjs/config": "2.0.0-beta.37",
"@blitzjs/next": "2.0.0-beta.37",
"@prisma/client": "4.6.1",
"blitz": "2.0.0-beta.32",
"blitz": "2.0.0-beta.37",
"lowdb": "3.0.0",
"next": "13.3.0",
"next": "14.0.4",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

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

View File

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../app/blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

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": "2.0.0-beta.32",
"@blitzjs/next": "2.0.0-beta.32",
"@blitzjs/rpc": "2.0.0-beta.32",
"blitz": "2.0.0-beta.32",
"next": "13.3.0",
"@blitzjs/config": "2.0.0-beta.37",
"@blitzjs/next": "2.0.0-beta.37",
"@blitzjs/rpc": "2.0.0-beta.37",
"blitz": "2.0.0-beta.37",
"next": "14.0.4",
"react": "18.2.0",
"react-dom": "18.2.0"
},

View File

@@ -1,3 +1,3 @@
import {rpcHandler} from "@blitzjs/rpc"
export default rpcHandler({onError: console.log})
export default rpcHandler({onError: (error, ctx) => console.log(error)})

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,6 +1,2 @@
const {withBlitz} = require("@blitzjs/next")
module.exports = withBlitz({
experimental: {
appDir: true,
},
})
module.exports = withBlitz({})

View File

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

View File

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../src/blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

View File

@@ -6,7 +6,7 @@ import {BlitzRpcPlugin} from "@blitzjs/rpc"
export const {withBlitz, useSession, queryClient, BlitzProvider} = setupBlitzClient({
plugins: [
AuthClientPlugin({
cookiePrefix: "web-cookie-prefix",
cookiePrefix: "auth-tests-cookie-prefix",
}),
BlitzRpcPlugin({}),
],

View File

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

View File

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../app/blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

View File

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

View File

@@ -1,10 +1,10 @@
import {describe, it, expect, beforeAll, vi} from "vitest"
import {act, screen, waitForElementToBeRemoved, waitFor} from "@testing-library/react"
import {useQuery, useInfiniteQuery, BlitzRpcPlugin, QueryClientProvider} from "@blitzjs/rpc"
import {act, screen, waitForElementToBeRemoved} from "@testing-library/react"
import {useQuery, useInfiniteQuery, BlitzRpcPlugin, BlitzProvider} from "@blitzjs/rpc"
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"
@@ -44,9 +44,9 @@ describe("useQuery", () => {
const {rerender} = render(ui(), {
wrapper: ({children}) => (
<QueryClientProvider client={globalThis.queryClient}>
<BlitzProvider>
<RouterContext.Provider value={mockRouter}>{children}</RouterContext.Provider>
</QueryClientProvider>
</BlitzProvider>
),
})
return [res, () => rerender(ui())]
@@ -117,9 +117,9 @@ describe("useQuery", () => {
const {rerender} = render(ui(), {
wrapper: ({children}) => (
<QueryClientProvider client={globalThis.queryClient}>
<BlitzProvider>
<RouterContext.Provider value={mockRouter}>{children}</RouterContext.Provider>
</QueryClientProvider>
</BlitzProvider>
),
})
})
@@ -163,9 +163,9 @@ describe("useInfiniteQuery", () => {
const {rerender} = render(ui(), {
wrapper: ({children}) => (
<QueryClientProvider client={globalThis.queryClient}>
<BlitzProvider>
<RouterContext.Provider value={mockRouter}>{children}</RouterContext.Provider>
</QueryClientProvider>
</BlitzProvider>
),
})
return [res, () => rerender(ui())]

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": "2.0.0-beta.32",
"@blitzjs/rpc": "2.0.0-beta.32",
"@blitzjs/next": "2.0.0-beta.37",
"@blitzjs/rpc": "2.0.0-beta.37",
"@prisma/client": "4.6.1",
"blitz": "2.0.0-beta.32",
"blitz": "2.0.0-beta.37",
"lowdb": "3.0.0",
"next": "13.3.0",
"next": "14.0.4",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "2.0.0-beta.32",
"@blitzjs/config": "2.0.0-beta.37",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",

View File

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../app/blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

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": "2.0.0-beta.32",
"@blitzjs/next": "2.0.0-beta.32",
"@blitzjs/rpc": "2.0.0-beta.32",
"blitz": "2.0.0-beta.32",
"next": "13.3.0",
"@blitzjs/config": "2.0.0-beta.37",
"@blitzjs/next": "2.0.0-beta.37",
"@blitzjs/rpc": "2.0.0-beta.37",
"blitz": "2.0.0-beta.37",
"next": "14.0.4",
"react": "18.2.0",
"react-dom": "18.2.0"
},

View File

@@ -1,3 +1,3 @@
import {rpcHandler} from "@blitzjs/rpc"
export default rpcHandler({onError: console.log})
export default rpcHandler({onError: (error, ctx) => console.log(error)})

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

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

View File

@@ -1,3 +1,3 @@
import {rpcHandler} from "@blitzjs/rpc"
export default rpcHandler({onError: console.log})
export default rpcHandler({onError: (error, ctx) => console.log(error)})

View File

@@ -162,13 +162,6 @@ function runTests(dev = false) {
5000 * 60 * 2,
)
})
if (!dev) {
it("should show warning with next export", async () => {
const {stderr} = await nextExport(appDir, {outdir: join(appDir, "out")}, {stderr: true})
expect(stderr).toContain("https://nextjs.org/docs/messages/api-routes-static-export")
})
}
}
describe("RPC", () => {

View File

@@ -13,8 +13,14 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
],
"strictNullChecks": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}

View File

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

View File

@@ -1,4 +1,4 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../app/blitz-server"
export default api(rpcHandler({onError: console.log}))
export default api(rpcHandler({onError: (error, ctx) => console.log(error)}))

View File

@@ -1,9 +1,9 @@
import React from "react"
import {vi} from "vitest"
import {QueryClient} from "@tanstack/react-query"
import {BlitzRpcPlugin, QueryClientProvider} from "@blitzjs/rpc"
import {BlitzRpcPlugin, BlitzProvider} 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>
@@ -39,22 +40,6 @@ export type BlitzProviderProps = {
contextSharing?: boolean
}
const BlitzProvider = ({
client,
contextSharing = false,
children,
}: BlitzProviderProps & {children: JSX.Element}) => {
if (globalThis.queryClient) {
return (
<QueryClientProvider client={globalThis.queryClient} contextSharing={contextSharing}>
{children}
</QueryClientProvider>
)
}
return children
}
const compose =
(...rest) =>
(x: React.ComponentType<any>) =>
@@ -74,7 +59,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.37",
"@blitzjs/next": "workspace:2.0.0-beta.37",
"@blitzjs/rpc": "workspace:2.0.0-beta.37",
"@tanstack/react-query": "4.13.0",
"@testing-library/react": "13.4.0",
"@types/express": "4.17.13",

View File

@@ -29,12 +29,12 @@
"husky": "8.0.2",
"jsdom": "^19.0.0",
"lint-staged": "13.0.3",
"next": "13.3.0",
"next": "14.0.4",
"only-allow": "1.1.0",
"prettier": "^2.7.1",
"prettier-plugin-prisma": "4.4.0",
"pretty-quick": "3.1.3",
"turbo": "1.10.7",
"turbo": "1.10.9",
"vitest": "0.25.3",
"wait-on": "6.0.1"
},
@@ -44,5 +44,10 @@
"ignoredRules": [
"EXTERNAL_MISMATCH"
]
},
"pnpm": {
"patchedDependencies": {
"next-auth@4.18.7": "patches/next-auth@4.18.7.patch"
}
}
}

View File

@@ -1,5 +1,71 @@
# @blitzjs/auth
## 2.0.0-beta.37
### Patch Changes
- b84c5bedb: Next 14 Compatibility
- Updated dependencies [86e8eb7c8]
- Updated dependencies [b84c5bedb]
- blitz@2.0.0-beta.37
## 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

View File

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

View File

@@ -1,6 +1,5 @@
import {fromBase64} from "b64-lite"
import _BadBehavior from "bad-behavior"
import {useEffect, useState} from "react"
import {UrlObject} from "url"
import React, {ComponentPropsWithoutRef} from "react"
import {
@@ -171,9 +170,9 @@ export const useSession = (options: UseSessionOptions = {}): ClientSession => {
initialState = {...emptyPublicData, isLoading: true}
}
const [session, setSession] = useState(initialState)
const [session, setSession] = React.useState(initialState)
useEffect(() => {
React.useEffect(() => {
// Initialize on mount
setSession({...getPublicDataStore().getData(), isLoading: false})
const subscription = getPublicDataStore().observable.subscribe((data) =>
@@ -186,8 +185,8 @@ export const useSession = (options: UseSessionOptions = {}): ClientSession => {
}
export const useAuthorizeIf = (condition?: boolean, role?: string | Array<string>) => {
const [mounted, setMounted] = useState(false)
useEffect(() => {
const [mounted, setMounted] = React.useState(false)
React.useEffect(() => {
setMounted(true)
}, [])
@@ -233,9 +232,9 @@ export const useAuthenticatedSession = (
}
export const useRedirectAuthenticated = (to: UrlObject | string) => {
const [mounted, setMounted] = useState(false)
const [mounted, setMounted] = React.useState(false)
useEffect(() => {
React.useEffect(() => {
setMounted(true)
}, [])
@@ -303,19 +302,19 @@ export function getAuthValues<TProps = any>(
function withBlitzAuthPlugin<TProps = any>(Page: ComponentType<TProps> | BlitzPage<TProps>) {
const AuthRoot = (props: ComponentProps<any>) => {
useSession({suspense: false})
const [mounted, setMounted] = useState(false)
const [mounted, setMounted] = React.useState(false)
useEffect(() => {
React.useEffect(() => {
setMounted(true)
}, [])
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,2 +1 @@
export * from "./passport/adapter"
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"

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