Compare commits
86 Commits
blitz@2.0.
...
@blitzjs/g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c738ecacbc | ||
|
|
ad0b087d9f | ||
|
|
dc694cf1cf | ||
|
|
4c221b655e | ||
|
|
c11f0401cf | ||
|
|
830b51d0dc | ||
|
|
bec9512e30 | ||
|
|
1493729d6b | ||
|
|
6bb5980da9 | ||
|
|
7310f7171d | ||
|
|
d855ee3e1d | ||
|
|
93851d90ca | ||
|
|
3ab05b3cda | ||
|
|
bb3dd56f7a | ||
|
|
1d9804a610 | ||
|
|
0fd1f9c9b1 | ||
|
|
b86b569d56 | ||
|
|
b405c1e876 | ||
|
|
c957828ea6 | ||
|
|
c78e5c4704 | ||
|
|
009664e0f5 | ||
|
|
3110522dca | ||
|
|
7269ac2bc5 | ||
|
|
7a7ce2229e | ||
|
|
10c23d3d20 | ||
|
|
d93b05d0ac | ||
|
|
aafdc5b4c4 | ||
|
|
37ef42811b | ||
|
|
34cc29e40c | ||
|
|
bee19a259d | ||
|
|
9ada0f6661 | ||
|
|
425559d360 | ||
|
|
0411689b1d | ||
|
|
0d3514cd27 | ||
|
|
a9edde6d83 | ||
|
|
5c5decbce2 | ||
|
|
e476beba39 | ||
|
|
1a1b23a7e8 | ||
|
|
ae0b714f69 | ||
|
|
7817fe3a85 | ||
|
|
30bb474abb | ||
|
|
135b30efde | ||
|
|
527e48ac3e | ||
|
|
b905270875 | ||
|
|
96ea5291e4 | ||
|
|
9c2e7d372c | ||
|
|
493d505b24 | ||
|
|
09da992bef | ||
|
|
bbac7906e8 | ||
|
|
21ca3a9b02 | ||
|
|
32274803d9 | ||
|
|
9ded8dacba | ||
|
|
80ffbeaa4c | ||
|
|
6bde1b07da | ||
|
|
b918055bf3 | ||
|
|
f9a2971f05 | ||
|
|
72b08f2269 | ||
|
|
2124a4d0c5 | ||
|
|
8aee25c58a | ||
|
|
f1003faf94 | ||
|
|
50468a3bb0 | ||
|
|
891d91bf4d | ||
|
|
f96c953457 | ||
|
|
a80d2a8f77 | ||
|
|
b336ad05f4 | ||
|
|
39ca0ef8bf | ||
|
|
4cad9cca25 | ||
|
|
b6fc940bf2 | ||
|
|
a946dd5889 | ||
|
|
e3750b049d | ||
|
|
fb01cc7788 | ||
|
|
ac8c412da2 | ||
|
|
dfd2408e95 | ||
|
|
9741287050 | ||
|
|
0e9c81abdc | ||
|
|
9e05d6e155 | ||
|
|
17f70e65ef | ||
|
|
0ddc5a8169 | ||
|
|
e6fb09d494 | ||
|
|
d846fc6be9 | ||
|
|
f5e80e3835 | ||
|
|
17ce29e5e4 | ||
|
|
46d9f81adf | ||
|
|
994cfc6292 | ||
|
|
7811748526 | ||
|
|
ce45368334 |
5
.changeset/bright-mangos-run.md
Normal file
5
.changeset/bright-mangos-run.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Add queryClient to RPC Plugin exports
|
||||
6
.changeset/eleven-humans-sort.md
Normal file
6
.changeset/eleven-humans-sort.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
codemod fixes
|
||||
5
.changeset/empty-turkeys-wave.md
Normal file
5
.changeset/empty-turkeys-wave.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Use `useRouter` from next/router in useParams function
|
||||
6
.changeset/four-brooms-juggle.md
Normal file
6
.changeset/four-brooms-juggle.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Add missing RouteUrlObject on Page.authenticate.redirectTo
|
||||
5
.changeset/fuzzy-jars-admire.md
Normal file
5
.changeset/fuzzy-jars-admire.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
fix codemod for wrapping \_app arrow function & fix codemod for nested pages directory
|
||||
5
.changeset/gentle-dogs-reply.md
Normal file
5
.changeset/gentle-dogs-reply.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Update queryClient import in codemod
|
||||
5
.changeset/good-insects-wink.md
Normal file
5
.changeset/good-insects-wink.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Allow passing optional type argument for ParamsType in GSSP
|
||||
5
.changeset/green-papayas-do.md
Normal file
5
.changeset/green-papayas-do.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Update codemod and template with a new queryClient import location
|
||||
6
.changeset/late-steaks-give.md
Normal file
6
.changeset/late-steaks-give.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Support RPC error middleware
|
||||
6
.changeset/lemon-games-press.md
Normal file
6
.changeset/lemon-games-press.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Update Next.js version and addBasePath location
|
||||
7
.changeset/lucky-cows-try.md
Normal file
7
.changeset/lucky-cows-try.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"blitz": patch
|
||||
"@blitzjs/auth": patch
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
rename middleware type for blitz server plugin
|
||||
5
.changeset/nervous-beds-travel.md
Normal file
5
.changeset/nervous-beds-travel.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
useParam & useParams functions now accessible from @blitzjs/next
|
||||
5
.changeset/nervous-dolls-rule.md
Normal file
5
.changeset/nervous-dolls-rule.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Move middlewares from blitz config to blitz server with codemod
|
||||
6
.changeset/new-coats-turn.md
Normal file
6
.changeset/new-coats-turn.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"blitz": patch
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Handle duplicate imports with Blitz upgrade-legacy codemod
|
||||
5
.changeset/olive-bees-buy.md
Normal file
5
.changeset/olive-bees-buy.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Fix templates source in RPC codemod step
|
||||
5
.changeset/olive-feet-rhyme.md
Normal file
5
.changeset/olive-feet-rhyme.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Add codemod to upgrade from legacy framework to the Blitz Toolkit
|
||||
@@ -12,49 +12,82 @@
|
||||
"@blitzjs/rpc": "2.0.0-alpha.0",
|
||||
"@blitzjs/config": "0.0.0",
|
||||
"@blitzjs/generator": "2.0.0-alpha.0",
|
||||
"@blitzjs/codemod": "2.0.0-alpha.0",
|
||||
"template": "0.0.0",
|
||||
"toolkit-app": "1.0.0",
|
||||
"test-qm": "0.0.0",
|
||||
"test-no-suspense": "0.0.0",
|
||||
"test-trailing-slash": "0.0.0"
|
||||
"test-trailing-slash": "0.0.0",
|
||||
"test-middleware": "0.0.0"
|
||||
},
|
||||
"changesets": [
|
||||
"big-phones-bow",
|
||||
"breezy-cameras-double",
|
||||
"bright-mangos-run",
|
||||
"cool-doors-invent",
|
||||
"dirty-monkeys-greet",
|
||||
"eleven-humans-sort",
|
||||
"empty-berries-rule",
|
||||
"empty-turkeys-wave",
|
||||
"fair-wombats-sneeze",
|
||||
"famous-kings-explain",
|
||||
"fast-trainers-kneel",
|
||||
"flat-bees-approve",
|
||||
"four-brooms-juggle",
|
||||
"four-meals-fry",
|
||||
"fuzzy-jars-admire",
|
||||
"gentle-dogs-reply",
|
||||
"good-insects-wink",
|
||||
"great-months-train",
|
||||
"green-papayas-do",
|
||||
"healthy-rice-shout",
|
||||
"hot-drinks-approve",
|
||||
"late-steaks-give",
|
||||
"lemon-games-press",
|
||||
"lovely-colts-share",
|
||||
"lucky-cows-try",
|
||||
"modern-cameras-pull",
|
||||
"moody-squids-cheer",
|
||||
"nervous-beds-travel",
|
||||
"nervous-dolls-rule",
|
||||
"new-coats-turn",
|
||||
"nice-starfishes-live",
|
||||
"nine-onions-admire",
|
||||
"ninety-pets-heal",
|
||||
"olive-bees-buy",
|
||||
"olive-feet-rhyme",
|
||||
"plenty-bottles-swim",
|
||||
"poor-peas-lick",
|
||||
"poor-penguins-look",
|
||||
"poor-shrimps-think",
|
||||
"purple-singers-greet",
|
||||
"quiet-feet-travel",
|
||||
"quiet-pans-hunt",
|
||||
"quiet-sloths-rule",
|
||||
"rich-chairs-invent",
|
||||
"rich-queens-travel",
|
||||
"sharp-falcons-begin",
|
||||
"shy-olives-hang",
|
||||
"silent-colts-reply",
|
||||
"slow-walls-poke",
|
||||
"small-socks-confess",
|
||||
"smooth-planets-admire",
|
||||
"strong-apes-reply",
|
||||
"stupid-walls-sell",
|
||||
"swift-drinks-dress",
|
||||
"tame-keys-reply",
|
||||
"tasty-news-collect",
|
||||
"ten-hairs-listen",
|
||||
"ten-rivers-burn",
|
||||
"tender-pianos-check",
|
||||
"thick-parrots-float",
|
||||
"thirty-countries-build",
|
||||
"twenty-beans-pump",
|
||||
"two-kiwis-help",
|
||||
"two-tigers-type",
|
||||
"unlucky-papayas-sleep",
|
||||
"violet-bags-leave",
|
||||
"violet-lions-help",
|
||||
"weak-suns-shave",
|
||||
"wicked-ghosts-cough",
|
||||
"wise-frogs-give"
|
||||
|
||||
7
.changeset/purple-singers-greet.md
Normal file
7
.changeset/purple-singers-greet.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
"@blitzjs/codemod": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
getQueryClient function & queryClient codemod updates & shared plugin config
|
||||
5
.changeset/quiet-pans-hunt.md
Normal file
5
.changeset/quiet-pans-hunt.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Removes the suspense wrapper from withBlitz since it's not needed
|
||||
5
.changeset/quiet-sloths-rule.md
Normal file
5
.changeset/quiet-sloths-rule.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Removes the check for when withBlitz is mounted before rendering the users app. We had this previously to avoid the react 18 suspense error being showin in development with nextjs.
|
||||
8
.changeset/rich-queens-travel.md
Normal file
8
.changeset/rich-queens-travel.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
"blitz": patch
|
||||
"@blitzjs/auth": patch
|
||||
"@blitzjs/next": patch
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Remove references to the logging package
|
||||
6
.changeset/shy-olives-hang.md
Normal file
6
.changeset/shy-olives-hang.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Update RPC plugin setup in templates
|
||||
6
.changeset/slow-walls-poke.md
Normal file
6
.changeset/slow-walls-poke.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Allow resolverPath to be a function which is ran for every file path that is converted to RPC Route
|
||||
5
.changeset/smooth-planets-admire.md
Normal file
5
.changeset/smooth-planets-admire.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Add missing \_document.tsx and 404.tsx pages to the new app templates
|
||||
5
.changeset/strong-apes-reply.md
Normal file
5
.changeset/strong-apes-reply.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Remove as any assertion for the PrismaStorage argument
|
||||
5
.changeset/tame-keys-reply.md
Normal file
5
.changeset/tame-keys-reply.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Add aliases for Blitz CLI commands
|
||||
6
.changeset/tasty-news-collect.md
Normal file
6
.changeset/tasty-news-collect.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"blitz": patch
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
init codemod generator
|
||||
5
.changeset/ten-hairs-listen.md
Normal file
5
.changeset/ten-hairs-listen.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Allow customizing PreviewData in gSSP
|
||||
5
.changeset/thick-parrots-float.md
Normal file
5
.changeset/thick-parrots-float.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
allow extension catch in getAllFiles codemod util
|
||||
5
.changeset/two-tigers-type.md
Normal file
5
.changeset/two-tigers-type.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Fix running bin commands with Blitz CLI
|
||||
5
.changeset/violet-bags-leave.md
Normal file
5
.changeset/violet-bags-leave.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Update templates directory for codemod
|
||||
5
.changeset/violet-lions-help.md
Normal file
5
.changeset/violet-lions-help.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Add resolverBasePath to Blitz config to change the way rpc routes are generated
|
||||
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -1,5 +1,5 @@
|
||||
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
|
||||
|
||||
* @flybayer @beerose
|
||||
* @flybayer @beerose @dillonraphael
|
||||
|
||||
packages/generator/templates**/* @flybayer
|
||||
|
||||
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@@ -7,9 +7,15 @@ on:
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
@@ -32,13 +38,21 @@ jobs:
|
||||
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
with:
|
||||
version: 6.32.6
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm install --no-frozen-lockfile
|
||||
- run: pnpm build
|
||||
|
||||
- name: Create Release Pull Request
|
||||
uses: changesets/action@v1
|
||||
uses: blitz-js/changesets-action@main
|
||||
with:
|
||||
publish: pnpm release
|
||||
createGithubReleases: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
# - name: Github Release
|
||||
# uses: release-drafter/release-drafter@v5.19.0
|
||||
# with:
|
||||
# config-name: release-drafter.yml
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
1
.npmrc
1
.npmrc
@@ -6,3 +6,4 @@ public-hoist-pattern[]=*types*
|
||||
public-hoist-pattern[]=*eslint*
|
||||
public-hoist-pattern[]=@prettier/plugin-*
|
||||
public-hoist-pattern[]=*prettier-plugin-*
|
||||
strict-peer-dependencies=false
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NotFoundError } from "blitz"
|
||||
import { db } from "db"
|
||||
import db from "db"
|
||||
import { authenticateUser } from "./login"
|
||||
import { ChangePassword } from "../validations"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { generateToken, hash256 } from "@blitzjs/auth"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import { db } from "db"
|
||||
import db from "db"
|
||||
import { forgotPasswordMailer } from "mailers/forgotPasswordMailer"
|
||||
import { ForgotPassword } from "../validations"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import { AuthenticationError } from "blitz"
|
||||
import { db } from "db"
|
||||
import db from "db"
|
||||
import { Role } from "types"
|
||||
import { Login } from "../validations"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SecurePassword, hash256 } from "@blitzjs/auth"
|
||||
import { db } from "db"
|
||||
import db from "db"
|
||||
import { ResetPassword } from "../validations"
|
||||
import login from "./login"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { db } from "db"
|
||||
import db from "db"
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { Role } from "types"
|
||||
|
||||
export default async function signup(input, ctx) {
|
||||
const blitzContext = ctx
|
||||
@@ -13,6 +14,7 @@ export default async function signup(input, ctx) {
|
||||
|
||||
await blitzContext.session.$create({
|
||||
userId: user.id,
|
||||
role: user.role as Role,
|
||||
})
|
||||
|
||||
return { userId: blitzContext.session.userId, ...user, email: input.email }
|
||||
|
||||
@@ -7,12 +7,6 @@ export const { withBlitz } = setupBlitzClient({
|
||||
AuthClientPlugin({
|
||||
cookiePrefix: "web-cookie-prefix",
|
||||
}),
|
||||
BlitzRpcPlugin({
|
||||
reactQueryOptions: {
|
||||
queries: {
|
||||
staleTime: 7000,
|
||||
},
|
||||
},
|
||||
}),
|
||||
BlitzRpcPlugin({}),
|
||||
],
|
||||
})
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { setupBlitzServer } from "@blitzjs/next"
|
||||
import { AuthServerPlugin, PrismaStorage } from "@blitzjs/auth"
|
||||
import { db } from "db"
|
||||
import db from "db"
|
||||
import { simpleRolesIsAuthorized } from "@blitzjs/auth"
|
||||
|
||||
const { gSSP, gSP, api } = setupBlitzServer({
|
||||
plugins: [
|
||||
AuthServerPlugin({
|
||||
cookiePrefix: "web-cookie-prefix",
|
||||
// TODO fix type
|
||||
storage: PrismaStorage(db as any),
|
||||
storage: PrismaStorage(db),
|
||||
isAuthorized: simpleRolesIsAuthorized,
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Ctx } from "blitz"
|
||||
import { db } from "db"
|
||||
import db from "db"
|
||||
|
||||
export default async function getCurrentUser(_ = null, { session }: Ctx) {
|
||||
if (!session.userId) return null
|
||||
|
||||
@@ -5,4 +5,4 @@ const EnhancedPrisma = enhancePrisma(PrismaClient)
|
||||
|
||||
export * from "@prisma/client"
|
||||
const db = new EnhancedPrisma()
|
||||
export { db }
|
||||
export default db
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { db } from "./index"
|
||||
import db from "./index"
|
||||
|
||||
/*
|
||||
* This seed function is executed when you run `blitz db seed`.
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@hookform/resolvers": "2.8.8",
|
||||
"@prisma/client": "3.9.0",
|
||||
"blitz": "workspace:2.0.0-alpha.29",
|
||||
"next": "12.1.6-canary.17",
|
||||
"blitz": "workspace:2.0.0-alpha.50",
|
||||
"next": "12.2.0",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0",
|
||||
"react-hook-form": "7.29.0",
|
||||
"ts-node": "10.7.0",
|
||||
"zod": "3.10.1"
|
||||
"zod": "3.17.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
|
||||
20
apps/toolkit-app/pages/404.tsx
Normal file
20
apps/toolkit-app/pages/404.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import Head from "next/head"
|
||||
import { ErrorComponent } from "@blitzjs/next"
|
||||
|
||||
// ------------------------------------------------------
|
||||
// This page is rendered if a route match is not found
|
||||
// ------------------------------------------------------
|
||||
export default function Page404() {
|
||||
const statusCode = 404
|
||||
const title = "This page could not be found"
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>
|
||||
{statusCode}: {title}
|
||||
</title>
|
||||
</Head>
|
||||
<ErrorComponent statusCode={statusCode} title={title} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
22
apps/toolkit-app/pages/_document.tsx
Normal file
22
apps/toolkit-app/pages/_document.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import Document, { Html, Main, NextScript, Head } from "next/document"
|
||||
|
||||
class MyDocument extends Document {
|
||||
// Only uncomment if you need to customize this behaviour
|
||||
// static async getInitialProps(ctx: DocumentContext) {
|
||||
// const initialProps = await Document.getInitialProps(ctx)
|
||||
// return {...initialProps}
|
||||
// }
|
||||
render() {
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Head />
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default MyDocument
|
||||
@@ -7,8 +7,7 @@ const {gSSP, gSP, api} = setupBlitzServer({
|
||||
plugins: [
|
||||
AuthServerPlugin({
|
||||
cookiePrefix: "webapp-cookie-prefix",
|
||||
// TODO fix type
|
||||
storage: PrismaStorage(db as any),
|
||||
storage: PrismaStorage(db),
|
||||
isAuthorized: simpleRolesIsAuthorized,
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"@types/passport-twitter": "1.0.37",
|
||||
"blitz": "workspace:*",
|
||||
"jest": "27.5.1",
|
||||
"next": "12.1.6-canary.17",
|
||||
"next": "12.2.0",
|
||||
"passport-mock-strategy": "2.0.0",
|
||||
"passport-twitter": "1.0.4",
|
||||
"prisma": "3.9.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {ErrorFallbackProps, ErrorComponent, ErrorBoundary, AppProps} from "@blitzjs/next"
|
||||
import {AuthenticationError, AuthorizationError} from "blitz"
|
||||
import React from "react"
|
||||
import React, {Suspense} from "react"
|
||||
import {withBlitz} from "app/blitz-client"
|
||||
|
||||
function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
@@ -26,7 +26,9 @@ function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
function MyApp({Component, pageProps}: AppProps) {
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
<Suspense fallback="Loading...">
|
||||
<Component {...pageProps} />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {setupBlitzServer} from "@blitzjs/next"
|
||||
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
|
||||
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {prisma as db} from "../prisma/index"
|
||||
import db from "../prisma/index"
|
||||
|
||||
const {gSSP, gSP, api} = setupBlitzServer({
|
||||
plugins: [
|
||||
AuthServerPlugin({
|
||||
cookiePrefix: "auth-tests-cookie-prefix",
|
||||
storage: PrismaStorage(db as any),
|
||||
storage: PrismaStorage(db),
|
||||
isAuthorized: simpleRolesIsAuthorized,
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"@prisma/client": "3.9.0",
|
||||
"blitz": "workspace:*",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.1.6-canary.17",
|
||||
"next": "12.2.0",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {ErrorFallbackProps, ErrorComponent, ErrorBoundary, AppProps} from "@blitzjs/next"
|
||||
import {AuthenticationError, AuthorizationError} from "blitz"
|
||||
import React from "react"
|
||||
import React, {Suspense} from "react"
|
||||
import {withBlitz} from "../app/blitz-client"
|
||||
|
||||
function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
@@ -25,9 +25,11 @@ function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
|
||||
function MyApp({Component, pageProps}: AppProps) {
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
<Suspense fallback="Loading...">
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {api} from "../../app/blitz-server"
|
||||
import {prisma} from "../../prisma/index"
|
||||
import prisma from "../../prisma/index"
|
||||
import {SecurePassword} from "@blitzjs/auth"
|
||||
import {Role} from "../../types"
|
||||
|
||||
export const authenticateUser = async (email: string, password: string) => {
|
||||
const user = await prisma.user.findFirst({where: {email}})
|
||||
@@ -26,6 +27,7 @@ export default api(async (req, res, ctx) => {
|
||||
|
||||
await blitzContext.session.$create({
|
||||
userId: user.id,
|
||||
role: user.role as Role,
|
||||
})
|
||||
|
||||
res.status(200).json({email: req.query.email, userId: blitzContext.session.userId})
|
||||
|
||||
@@ -5,4 +5,4 @@ const EnhancedPrisma = enhancePrisma(PrismaClient)
|
||||
|
||||
export * from "@prisma/client"
|
||||
const prisma = new EnhancedPrisma()
|
||||
export {prisma}
|
||||
export default prisma
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {prisma} from "./index"
|
||||
import prisma from "./index"
|
||||
import {SecurePassword} from "@blitzjs/auth"
|
||||
|
||||
const seed = async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "@blitzjs/config/tsconfig.nextjs.json",
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"react": ["./node_modules/@types/react"]
|
||||
|
||||
15
integration-tests/auth/types.ts
Normal file
15
integration-tests/auth/types.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {User} from "./prisma"
|
||||
|
||||
export type Role = "ADMIN" | "USER"
|
||||
|
||||
declare module "@blitzjs/auth" {
|
||||
export interface Session {
|
||||
isAuthorized: SimpleRolesIsAuthorized<Role>
|
||||
PublicData: {
|
||||
userId: User["id"]
|
||||
role: Role
|
||||
views?: number
|
||||
}
|
||||
}
|
||||
}
|
||||
2
integration-tests/middleware/.env
Normal file
2
integration-tests/middleware/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
SESSION_SECRET_KEY=hsdenhJfpLHrGjgdgg3jdF8g2bYD2PaQ
|
||||
HEADLESS=true
|
||||
1
integration-tests/middleware/.eslintrc.js
Normal file
1
integration-tests/middleware/.eslintrc.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
3
integration-tests/middleware/.gitignore
vendored
Normal file
3
integration-tests/middleware/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
# Keep environment variables out of version control
|
||||
*.sqlite
|
||||
5
integration-tests/middleware/app/blitz-client.ts
Normal file
5
integration-tests/middleware/app/blitz-client.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import {setupBlitzClient} from "@blitzjs/next"
|
||||
|
||||
const {withBlitz} = setupBlitzClient({plugins: []})
|
||||
|
||||
export {withBlitz}
|
||||
7
integration-tests/middleware/app/blitz-server.ts
Normal file
7
integration-tests/middleware/app/blitz-server.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import {setupBlitzServer} from "@blitzjs/next"
|
||||
|
||||
const {gSSP, gSP, api} = setupBlitzServer({
|
||||
plugins: [],
|
||||
})
|
||||
|
||||
export {gSSP, gSP, api}
|
||||
3
integration-tests/middleware/app/queries/getBasic.ts
Normal file
3
integration-tests/middleware/app/queries/getBasic.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default async function getBasic() {
|
||||
return {success: true}
|
||||
}
|
||||
7
integration-tests/middleware/middleware.ts
Normal file
7
integration-tests/middleware/middleware.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import {NextResponse} from "next/server"
|
||||
|
||||
export function middleware() {
|
||||
const response = NextResponse.next()
|
||||
response.headers.set("global-middleware", "true")
|
||||
return response
|
||||
}
|
||||
5
integration-tests/middleware/next-env.d.ts
vendored
Normal file
5
integration-tests/middleware/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
2
integration-tests/middleware/next.config.js
Normal file
2
integration-tests/middleware/next.config.js
Normal file
@@ -0,0 +1,2 @@
|
||||
const {withBlitz} = require("@blitzjs/next")
|
||||
module.exports = withBlitz({})
|
||||
34
integration-tests/middleware/package.json
Normal file
34
integration-tests/middleware/package.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "test-middleware",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start:dev": "next dev",
|
||||
"test": "vitest run",
|
||||
"test-watch": "vitest",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/config": "workspace:*",
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"blitz": "workspace:*",
|
||||
"next": "12.2.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/node-fetch": "2.6.1",
|
||||
"@types/react": "18.0.1",
|
||||
"eslint": "7.32.0",
|
||||
"fs-extra": "10.0.1",
|
||||
"get-port": "6.1.2",
|
||||
"node-fetch": "3.2.3",
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
36
integration-tests/middleware/pages/_app.tsx
Normal file
36
integration-tests/middleware/pages/_app.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import {ErrorFallbackProps, ErrorComponent, ErrorBoundary, AppProps} from "@blitzjs/next"
|
||||
import {AuthenticationError, AuthorizationError} from "blitz"
|
||||
import React, {Suspense} from "react"
|
||||
import {withBlitz} from "../app/blitz-client"
|
||||
|
||||
function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
if (error instanceof AuthenticationError) {
|
||||
return <div id="error">Error: You are not authenticated</div>
|
||||
} else if (error instanceof AuthorizationError) {
|
||||
return (
|
||||
<ErrorComponent
|
||||
statusCode={error.statusCode}
|
||||
title="Sorry, you are not authorized to access this"
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<ErrorComponent
|
||||
statusCode={(error as any)?.statusCode || 400}
|
||||
title={error.message || error.name}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function MyApp({Component, pageProps}: AppProps) {
|
||||
return (
|
||||
<Suspense fallback="Loading...">
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
export default withBlitz(MyApp)
|
||||
@@ -0,0 +1,3 @@
|
||||
import {rpcHandler} from "@blitzjs/rpc"
|
||||
|
||||
export default rpcHandler({onError: console.log})
|
||||
5
integration-tests/middleware/pages/api/test.ts
Normal file
5
integration-tests/middleware/pages/api/test.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import {api} from "../../app/blitz-server"
|
||||
|
||||
export default api((_req, res) => {
|
||||
res.status(200).json({success: true})
|
||||
})
|
||||
11
integration-tests/middleware/pages/index.tsx
Normal file
11
integration-tests/middleware/pages/index.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
export const getServerSideProps = () => {
|
||||
return {props: {}}
|
||||
}
|
||||
|
||||
export default function Web() {
|
||||
return (
|
||||
<div>
|
||||
<h1>Web</h1>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
72
integration-tests/middleware/test/index.test.ts
Normal file
72
integration-tests/middleware/test/index.test.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import {describe, it, expect, beforeAll, afterAll} from "vitest"
|
||||
import {
|
||||
killApp,
|
||||
findPort,
|
||||
launchApp,
|
||||
nextBuild,
|
||||
nextStart,
|
||||
fetchViaHTTP,
|
||||
} from "../../utils/next-test-utils"
|
||||
import {join} from "path"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
const appDir = join(__dirname, "../")
|
||||
|
||||
const runTests = () => {
|
||||
describe("Middleware", () => {
|
||||
describe("global middleware", () => {
|
||||
it(
|
||||
"should call global middleware on api calls",
|
||||
async () => {
|
||||
const res = await fetchViaHTTP(appPort, "/api/test", null, {
|
||||
method: "GET",
|
||||
})
|
||||
expect(res.headers.get("global-middleware")).toBe("true")
|
||||
},
|
||||
5000 * 60 * 2,
|
||||
)
|
||||
|
||||
it(
|
||||
"should call global middleware on rpc calls",
|
||||
async () => {
|
||||
const res = await fetchViaHTTP(appPort, "/api/rpc/getBasic", null, {
|
||||
method: "GET",
|
||||
})
|
||||
expect(res.headers.get("global-middleware")).toBe("true")
|
||||
},
|
||||
5000 * 60 * 2,
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
describe("Middleware Tests", () => {
|
||||
describe("dev mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
appPort = await findPort()
|
||||
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}, 5000 * 60 * 2)
|
||||
afterAll(async () => await killApp(app))
|
||||
runTests()
|
||||
})
|
||||
|
||||
describe("server mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await nextBuild(appDir)
|
||||
appPort = await findPort()
|
||||
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}, 5000 * 60 * 2)
|
||||
afterAll(async () => await killApp(app))
|
||||
|
||||
runTests()
|
||||
})
|
||||
})
|
||||
11
integration-tests/middleware/tsconfig.json
Normal file
11
integration-tests/middleware/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "@blitzjs/config/tsconfig.nextjs.json",
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"react": ["./node_modules/@types/react"]
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules"],
|
||||
"baseUrl": "."
|
||||
}
|
||||
@@ -7,13 +7,7 @@ const {withBlitz} = setupBlitzClient({
|
||||
AuthClientPlugin({
|
||||
cookiePrefix: "no-suspense-tests-cookie-prefix",
|
||||
}),
|
||||
BlitzRpcPlugin({
|
||||
reactQueryOptions: {
|
||||
queries: {
|
||||
staleTime: 7000,
|
||||
},
|
||||
},
|
||||
}),
|
||||
BlitzRpcPlugin({}),
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {setupBlitzServer} from "@blitzjs/next"
|
||||
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
|
||||
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {prisma as db} from "../prisma/index"
|
||||
import db from "../prisma/index"
|
||||
|
||||
const {gSSP, gSP, api} = setupBlitzServer({
|
||||
plugins: [
|
||||
AuthServerPlugin({
|
||||
cookiePrefix: "no-suspense-tests-cookie-prefix",
|
||||
storage: PrismaStorage(db as any),
|
||||
storage: PrismaStorage(db),
|
||||
isAuthorized: simpleRolesIsAuthorized,
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"@prisma/client": "3.9.0",
|
||||
"blitz": "workspace:*",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.1.6-canary.17",
|
||||
"next": "12.2.0",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {ErrorFallbackProps, ErrorComponent, ErrorBoundary, AppProps} from "@blitzjs/next"
|
||||
import {AuthenticationError, AuthorizationError} from "blitz"
|
||||
import React from "react"
|
||||
import React, {Suspense} from "react"
|
||||
import {withBlitz} from "../app/blitz-client"
|
||||
|
||||
function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
@@ -25,9 +25,11 @@ function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
|
||||
function MyApp({Component, pageProps}: AppProps) {
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
<Suspense fallback="Loading...">
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@ const EnhancedPrisma = enhancePrisma(PrismaClient)
|
||||
|
||||
export * from "@prisma/client"
|
||||
const prisma = new EnhancedPrisma()
|
||||
export {prisma}
|
||||
export default prisma
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {prisma} from "./index"
|
||||
import prisma from "./index"
|
||||
|
||||
const seed = async () => {
|
||||
await prisma.$reset()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "@blitzjs/config/tsconfig.nextjs.json",
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"react": ["./node_modules/@types/react"]
|
||||
|
||||
15
integration-tests/no-suspense/types.ts
Normal file
15
integration-tests/no-suspense/types.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {User} from "./prisma"
|
||||
|
||||
export type Role = "ADMIN" | "USER"
|
||||
|
||||
declare module "@blitzjs/auth" {
|
||||
export interface Session {
|
||||
isAuthorized: SimpleRolesIsAuthorized<Role>
|
||||
PublicData: {
|
||||
userId: User["id"]
|
||||
role: Role
|
||||
views?: number
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@prisma/client": "3.9.0",
|
||||
"blitz": "workspace:*",
|
||||
"next": "12.1.6-canary.17",
|
||||
"next": "12.2.0",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {withBlitz} = require("@blitzjs/next")
|
||||
module.exports = withBlitz({
|
||||
target: 'experimental-serverless-trace',
|
||||
target: "experimental-serverless-trace",
|
||||
})
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"blitz": "workspace:*",
|
||||
"next": "12.1.6-canary.17",
|
||||
"next": "12.2.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0"
|
||||
},
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
@@ -7,13 +7,7 @@ const {withBlitz} = setupBlitzClient({
|
||||
AuthClientPlugin({
|
||||
cookiePrefix: "trailing-slash-tests-cookie-prefix",
|
||||
}),
|
||||
BlitzRpcPlugin({
|
||||
reactQueryOptions: {
|
||||
queries: {
|
||||
staleTime: 7000,
|
||||
},
|
||||
},
|
||||
}),
|
||||
BlitzRpcPlugin({}),
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {setupBlitzServer} from "@blitzjs/next"
|
||||
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
|
||||
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {prisma as db} from "../prisma/index"
|
||||
import db from "../db"
|
||||
|
||||
const {gSSP, gSP, api} = setupBlitzServer({
|
||||
plugins: [
|
||||
AuthServerPlugin({
|
||||
cookiePrefix: "trailing-slash-tests-cookie-prefix",
|
||||
storage: PrismaStorage(db as any),
|
||||
storage: PrismaStorage(db),
|
||||
isAuthorized: simpleRolesIsAuthorized,
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -5,4 +5,4 @@ const EnhancedPrisma = enhancePrisma(PrismaClient)
|
||||
|
||||
export * from "@prisma/client"
|
||||
const prisma = new EnhancedPrisma()
|
||||
export {prisma}
|
||||
export default prisma
|
||||
@@ -1,4 +1,4 @@
|
||||
import {prisma} from "./index"
|
||||
import prisma from "./index"
|
||||
|
||||
const seed = async () => {
|
||||
await prisma.$reset()
|
||||
@@ -12,6 +12,9 @@
|
||||
"prisma:start": "prisma generate && prisma migrate deploy",
|
||||
"prisma:studio": "prisma studio"
|
||||
},
|
||||
"prisma": {
|
||||
"schema": "db/schema.prisma"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:*",
|
||||
"@blitzjs/next": "workspace:*",
|
||||
@@ -19,7 +22,7 @@
|
||||
"@prisma/client": "3.9.0",
|
||||
"blitz": "workspace:*",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.1.6-canary.17",
|
||||
"next": "12.2.0",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {ErrorFallbackProps, ErrorComponent, ErrorBoundary, AppProps} from "@blitzjs/next"
|
||||
import {AuthenticationError, AuthorizationError} from "blitz"
|
||||
import React from "react"
|
||||
import React, {Suspense} from "react"
|
||||
import {withBlitz} from "../app/blitz-client"
|
||||
|
||||
function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
@@ -25,9 +25,11 @@ function RootErrorFallback({error}: ErrorFallbackProps) {
|
||||
|
||||
function MyApp({Component, pageProps}: AppProps) {
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
<Suspense fallback="Loading...">
|
||||
<ErrorBoundary FallbackComponent={RootErrorFallback}>
|
||||
<Component {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "@blitzjs/config/tsconfig.nextjs.json",
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"react": ["./node_modules/@types/react"]
|
||||
|
||||
15
integration-tests/trailing-slash/types.ts
Normal file
15
integration-tests/trailing-slash/types.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {User} from "./db"
|
||||
|
||||
export type Role = "ADMIN" | "USER"
|
||||
|
||||
declare module "@blitzjs/auth" {
|
||||
export interface Session {
|
||||
isAuthorized: SimpleRolesIsAuthorized<Role>
|
||||
PublicData: {
|
||||
userId: User["id"]
|
||||
role: Role
|
||||
views?: number
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,21 +80,7 @@ const BlitzWrapper = ({plugins, children}) => {
|
||||
export function render(ui: RenderUI, {wrapper, router, ...options}: RenderOptions = {}) {
|
||||
if (!wrapper) {
|
||||
wrapper = ({children}) => {
|
||||
return (
|
||||
<BlitzWrapper
|
||||
plugins={[
|
||||
BlitzRpcPlugin({
|
||||
reactQueryOptions: {
|
||||
queries: {
|
||||
staleTime: 7000,
|
||||
},
|
||||
},
|
||||
}),
|
||||
]}
|
||||
>
|
||||
{children}
|
||||
</BlitzWrapper>
|
||||
)
|
||||
return <BlitzWrapper plugins={[BlitzRpcPlugin({})]}>{children}</BlitzWrapper>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,8 @@
|
||||
"husky": "7.0.4",
|
||||
"jsdom": "^19.0.0",
|
||||
"lint-staged": "12.1.7",
|
||||
"next": "12.1.6-canary.17",
|
||||
"next": "12.2.0",
|
||||
"only-allow": "1.1.0",
|
||||
"patch-package": "6.4.7",
|
||||
"prettier": "^2.5.1",
|
||||
"prettier-plugin-prisma": "3.8.0",
|
||||
"pretty-quick": "3.1.3",
|
||||
@@ -39,5 +38,5 @@
|
||||
"wait-on": "6.0.1"
|
||||
},
|
||||
"npmClient": "pnpm",
|
||||
"packageManager": "pnpm@6.21.0"
|
||||
"packageManager": "pnpm@7.4.0-1"
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user