Compare commits
20 Commits
@blitzjs/c
...
feature/ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b17d0779d | ||
|
|
b5d2b3cd95 | ||
|
|
8abf24e93c | ||
|
|
5d0e426f23 | ||
|
|
31a1f2c959 | ||
|
|
1ba606dda2 | ||
|
|
5142c04fc1 | ||
|
|
d017699b28 | ||
|
|
2c088ce199 | ||
|
|
a8046e604a | ||
|
|
00b64c402f | ||
|
|
0e33972bc0 | ||
|
|
25ebbbe77b | ||
|
|
6856e832e5 | ||
|
|
927c4afcc8 | ||
|
|
06241b24e3 | ||
|
|
9fe1cb5c86 | ||
|
|
c5a37ac12d | ||
|
|
162dc98508 | ||
|
|
29e7d641ca |
@@ -10,4 +10,4 @@
|
||||
|
||||
Bump react, react-dom, @types/react and next versions
|
||||
|
||||
This fixes a console warning: `Warning: Received `true` for a non-boolean attribute `global`.` when using `styled-jsx`. Versions bump also fixes React Hydration error that happens on and off when using `redirectAuthenticatedTo`.
|
||||
This fixes a console warning: `Warning: Received `true`for a non-boolean attribute`global`.` when using `styled-jsx`. Versions bump also fixes React Hydration error that happens on and off when using `redirectAuthenticatedTo`.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
Add DocumentProps & DocumentContext to the codemod import map
|
||||
|
||||
Add DocumentProps & DocumentContext to the codemod import map
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Fix `cannot find module db error` in JavaScript template. Replace requiring the config using `esbuild` with parsing using `jscodeshift` to get the `cliConfig` values. Added logic to find the `blitz-server` file in `src` directory
|
||||
Fix `cannot find module db error` in JavaScript template. Replace requiring the config using `esbuild` with parsing using `jscodeshift` to get the `cliConfig` values. Added logic to find the `blitz-server` file in `src` directory
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Fix Custom Server TS error - add `es6` target config to esbuild
|
||||
Fix Custom Server TS error - add `es6` target config to esbuild
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
"blitz": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Fixes the supports-color warning for pnpm
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -5,7 +5,7 @@ To make sure your PR is handled as smoothly as possible please:
|
||||
- Choose & follow the right checklist for the change that you're making:
|
||||
|
||||
Please make sure to add a changeset. Run `pnpm changeset` in the root directory to do so.
|
||||
Then select updated Blitz packages when prompted, and add a short message describing the changes.
|
||||
Then select updated Blitz packages when prompted, and add a short message describing the changes.
|
||||
The message should be user-facing — explain **what** was changed, not **how**.
|
||||
Ignore if there are no user-facing changes.
|
||||
-->
|
||||
|
||||
6
.github/workflows/main.yml
vendored
6
.github/workflows/main.yml
vendored
@@ -7,8 +7,8 @@ on:
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
|
||||
jobs:
|
||||
@@ -143,7 +143,7 @@ jobs:
|
||||
|
||||
- name: Install playwright
|
||||
run: |
|
||||
pnpx playwright@1.28.0 install --with-deps
|
||||
pnpx playwright@1.28.0 install --with-deps
|
||||
shell: bash
|
||||
|
||||
- name: Build
|
||||
|
||||
15
.github/workflows/pr-release.yml
vendored
15
.github/workflows/pr-release.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
||||
uses: eficode/resolve-pr-refs@main
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ steps.refs.outputs.head_ref }}
|
||||
@@ -39,18 +39,18 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
cache: 'pnpm'
|
||||
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Short SHA
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
- name: Extract the snapshot name from comment body
|
||||
id: getSnapshotName
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
script: |
|
||||
const splitComment = context.payload.comment.body.split(' ');
|
||||
if(splitComment.length !== 2) {
|
||||
return "${{ steps.vars.outputs.sha_short }}";
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
env:
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
|
||||
- name: Build Packages
|
||||
@@ -99,4 +99,3 @@ jobs:
|
||||
repo: context.repo.repo,
|
||||
body: '```\n' + process.env.MESSAGE + '\n```',
|
||||
})
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# toolkit-app-passportjs
|
||||
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
"version": "1.0.1-alpha.16",
|
||||
"scripts": {
|
||||
"start:dev": "pnpm run prisma:start && blitz dev",
|
||||
"buildapp": "pnpm blitz codegen && pnpm prisma generate && next build",
|
||||
"start:full": "pnpm buildapp && pnpm start",
|
||||
"start": "next start",
|
||||
"buildapp": "pnpm blitz codegen && pnpm prisma generate && next build",
|
||||
"lint": "next lint",
|
||||
"prisma:start": "prisma generate && prisma migrate deploy",
|
||||
"prisma:studio": "prisma studio",
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start:dev": "pnpm run prisma:start && next dev",
|
||||
"buildapp": "pnpm blitz codegen && pnpm prisma generate && next build",
|
||||
"start": "next start",
|
||||
"start:dev": "pnpm run prisma:start && next dev",
|
||||
"start:full": "pnpm buildapp && pnpm start",
|
||||
"buildapp": "pnpm blitz codegen && pnpm prisma generate && next build",
|
||||
"lint": "next lint",
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
|
||||
"prisma:start": "prisma generate && prisma migrate deploy",
|
||||
|
||||
10
apps/web/src/mutations/revalidate.ts
Normal file
10
apps/web/src/mutations/revalidate.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import {resolver} from "@blitzjs/rpc"
|
||||
import {Routes} from "@blitzjs/next"
|
||||
|
||||
const revalidateFn = resolver.pipe(async (_, ctx) => {
|
||||
await ctx.revalidatePage(Routes.PageWithGsp())
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
export default revalidateFn
|
||||
@@ -1,4 +1,7 @@
|
||||
import {gSP} from "src/blitz-server"
|
||||
import React from "react"
|
||||
import {gSP} from "app/blitz-server"
|
||||
import {useMutation} from "@blitzjs/rpc"
|
||||
import revalidateFn from "app/mutations/revalidate"
|
||||
|
||||
export const getStaticProps = gSP<{data: {test: string}}>(async ({ctx}) => {
|
||||
return {
|
||||
@@ -12,7 +15,18 @@ export const getStaticProps = gSP<{data: {test: string}}>(async ({ctx}) => {
|
||||
})
|
||||
|
||||
function PageWithGsp({data}) {
|
||||
return <div>{JSON.stringify(data, null, 2)}</div>
|
||||
const [prefetch, {isLoading}] = useMutation(revalidateFn)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button onClick={() => prefetch()} disabled={isLoading}>
|
||||
Revalidate GSP data
|
||||
</button>
|
||||
<br />
|
||||
|
||||
{JSON.stringify(data, null, 2)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default PageWithGsp
|
||||
|
||||
@@ -6,4 +6,3 @@ export default defineConfig({
|
||||
hookTimeout: 100000,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -18,7 +18,13 @@ import {
|
||||
BlitzLogger,
|
||||
initializeLogger,
|
||||
} from "blitz"
|
||||
import {handleRequestWithMiddleware, startWatcher, stopWatcher} from "blitz"
|
||||
import {
|
||||
handleRequestWithMiddleware,
|
||||
startWatcher,
|
||||
stopWatcher,
|
||||
RouteUrlObject,
|
||||
isRouteUrlObject,
|
||||
} from "blitz"
|
||||
import {
|
||||
dehydrate,
|
||||
getInfiniteQueryKey,
|
||||
@@ -29,11 +35,12 @@ import {
|
||||
} from "@blitzjs/rpc"
|
||||
import {DefaultOptions, QueryClient} from "@tanstack/react-query"
|
||||
import {IncomingMessage, ServerResponse} from "http"
|
||||
import {withSuperJsonProps} from "./superjson"
|
||||
import {ParsedUrlQuery} from "querystring"
|
||||
import {PreviewData} from "next/types"
|
||||
import {resolveHref} from "next/dist/shared/lib/router/router"
|
||||
import {RouteUrlObject, isRouteUrlObject} from "blitz"
|
||||
|
||||
import {withSuperJsonProps} from "./superjson"
|
||||
import {revalidateMiddleware} from "./next-revalidate"
|
||||
|
||||
export * from "./index-browser"
|
||||
|
||||
@@ -94,7 +101,7 @@ export type BlitzGSPHandler<
|
||||
> = ({
|
||||
ctx,
|
||||
...args
|
||||
}: Parameters<GetStaticProps<TProps, Query, PD>>[0] & {ctx: Ctx}) =>
|
||||
}: Parameters<GetStaticProps<TProps, Query, PD>>[0] & {ctx: Omit<Ctx, "revalidatePage">}) =>
|
||||
| Promise<BlitzGSPResult<TProps>>
|
||||
| BlitzGSPResult<TProps>
|
||||
|
||||
@@ -133,7 +140,7 @@ const prefetchQueryFactory = (
|
||||
export const setupBlitzServer = ({plugins, onError, logger}: SetupBlitzOptions) => {
|
||||
initializeLogger(logger ?? BlitzLogger())
|
||||
|
||||
const middlewares = plugins.flatMap((p) => p.requestMiddlewares)
|
||||
const middlewares = [...plugins.flatMap((p) => p.requestMiddlewares), revalidateMiddleware]
|
||||
const contextMiddleware = plugins.flatMap((p) => p.contextMiddleware).filter(Boolean)
|
||||
|
||||
const gSSP =
|
||||
@@ -185,6 +192,9 @@ export const setupBlitzServer = ({plugins, onError, logger}: SetupBlitzOptions)
|
||||
|
||||
ctx.prefetchQuery = prefetchQuery
|
||||
ctx.prefetchInfiniteQuery = (...args) => prefetchQuery(...args, true)
|
||||
ctx.revalidatePage = () => {
|
||||
throw new Error("revalidatePage is not supported in GSP")
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await handler({...context, ctx: ctx})
|
||||
@@ -309,5 +319,7 @@ declare module "blitz" {
|
||||
export interface Ctx {
|
||||
prefetchQuery: PrefetchQueryFn
|
||||
prefetchInfiniteQuery: PrefetchQueryFn
|
||||
|
||||
revalidatePage: NextApiResponse["revalidate"]
|
||||
}
|
||||
}
|
||||
|
||||
42
packages/blitz-next/src/next-revalidate.ts
Normal file
42
packages/blitz-next/src/next-revalidate.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
// copied from https://github.com/blitz-js/blitz/blob/a8046e604ace8bf544c544972328232820cd3d26/packages/blitz-auth/src/server/auth-sessions.ts#L127
|
||||
|
||||
import {IncomingMessage, ServerResponse} from "http"
|
||||
import {UrlObject} from "url"
|
||||
|
||||
import {Ctx, RequestMiddleware} from "blitz"
|
||||
import {NextApiResponse} from "next"
|
||||
import {NextRouter, resolveHref} from "next/dist/shared/lib/router/router"
|
||||
|
||||
export function ensureMiddlewareResponse(
|
||||
res: ServerResponse & {[key: string]: any},
|
||||
): asserts res is ServerResponse & {blitzCtx: Ctx} {
|
||||
if (!("blitzCtx" in res)) {
|
||||
res.blitzCtx = {} as Ctx
|
||||
}
|
||||
}
|
||||
|
||||
export function ensureResponseHasRevalidate(
|
||||
res: ServerResponse & {[key: string]: any},
|
||||
): res is ServerResponse & {revalidate: NextApiResponse["revalidate"]} {
|
||||
return !("revalidate" in res)
|
||||
}
|
||||
|
||||
export const revalidateMiddleware: RequestMiddleware<
|
||||
IncomingMessage,
|
||||
ServerResponse,
|
||||
void | Promise<void>
|
||||
> = (req, res, next) => {
|
||||
ensureMiddlewareResponse(res)
|
||||
if (!ensureResponseHasRevalidate(res)) {
|
||||
return next()
|
||||
}
|
||||
|
||||
if (!("revalidatePage" in res.blitzCtx)) {
|
||||
res.blitzCtx.revalidatePage = (
|
||||
url: UrlObject | string,
|
||||
opts?: Parameters<NextApiResponse["revalidate"]>[1],
|
||||
) => res.revalidate(resolveHref({} as NextRouter, url, false), opts)
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export const PAGES_DIR_ALIAS = "private-next-pages"
|
||||
|
||||
/* Fetch next.js config */
|
||||
export const VALID_LOADERS = ["default", "imgix", "cloudinary", "akamai", "custom"] as const
|
||||
export type LoaderValue = typeof VALID_LOADERS[number]
|
||||
export type LoaderValue = (typeof VALID_LOADERS)[number]
|
||||
export type ImageConfig = {
|
||||
deviceSizes: number[]
|
||||
imageSizes: number[]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {IncomingMessage, ServerResponse} from "http"
|
||||
import {compose, Ctx, RequestMiddleware, MiddlewareNext, MiddlewareResponse} from "./index-server"
|
||||
import {compose, RequestMiddleware, MiddlewareNext, MiddlewareResponse} from "./index-server"
|
||||
|
||||
export async function handleRequestWithMiddleware<
|
||||
Req extends IncomingMessage = IncomingMessage,
|
||||
@@ -17,9 +17,6 @@ export async function handleRequestWithMiddleware<
|
||||
stackPrintOnError?: boolean
|
||||
} = {},
|
||||
) {
|
||||
if (!(res as unknown as MiddlewareResponse).blitzCtx) {
|
||||
;(res as unknown as MiddlewareResponse).blitzCtx = {} as Ctx
|
||||
}
|
||||
if (!(res as any)._blitz) {
|
||||
;(res as any)._blitz = {}
|
||||
}
|
||||
|
||||
7287
pnpm-lock.yaml
generated
7287
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user