Skip to content

Commit 28a7904

Browse files
feat: export BlitzServerMiddleware from blitz-next (#4296)
* feat: export `BlitzServerMiddleware` from blitz-next * Create sixty-pants-hunt.md --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent dd604c7 commit 28a7904

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.changeset/sixty-pants-hunt.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@blitzjs/next": patch
3+
"blitz": patch
4+
---
5+
6+
feat: export `BlitzServerMiddleware` from blitz-next with stronger types

packages/blitz-next/src/index-server.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
RouteUrlObject,
2323
startWatcher,
2424
stopWatcher,
25+
RequestMiddleware,
2526
} from "blitz"
2627
import {
2728
getInfiniteQueryKey,
@@ -347,3 +348,15 @@ declare module "blitz" {
347348
prefetchInfiniteQuery: PrefetchQueryFn
348349
}
349350
}
351+
352+
export const BlitzServerMiddleware = <
353+
TMiddleware extends RequestMiddleware<NextApiRequest, BlitzNextApiResponse> = RequestMiddleware<
354+
NextApiRequest,
355+
BlitzNextApiResponse
356+
>,
357+
>(
358+
middleware: TMiddleware,
359+
): BlitzServerPlugin<{}> => ({
360+
requestMiddlewares: [middleware],
361+
exports: () => ({}),
362+
})

0 commit comments

Comments
 (0)