Skip to content

Commit

Permalink
feat: export BlitzServerMiddleware from blitz-next (#4296)
Browse files Browse the repository at this point in the history
* feat: export `BlitzServerMiddleware` from blitz-next

* Create sixty-pants-hunt.md

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
siddhsuresh and kodiakhq[bot] authored Feb 6, 2024
1 parent dd604c7 commit 28a7904
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/sixty-pants-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@blitzjs/next": patch
"blitz": patch
---

feat: export `BlitzServerMiddleware` from blitz-next with stronger types
13 changes: 13 additions & 0 deletions packages/blitz-next/src/index-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
RouteUrlObject,
startWatcher,
stopWatcher,
RequestMiddleware,
} from "blitz"
import {
getInfiniteQueryKey,
Expand Down Expand Up @@ -347,3 +348,15 @@ declare module "blitz" {
prefetchInfiniteQuery: PrefetchQueryFn
}
}

export const BlitzServerMiddleware = <
TMiddleware extends RequestMiddleware<NextApiRequest, BlitzNextApiResponse> = RequestMiddleware<
NextApiRequest,
BlitzNextApiResponse
>,
>(
middleware: TMiddleware,
): BlitzServerPlugin<{}> => ({
requestMiddlewares: [middleware],
exports: () => ({}),
})

0 comments on commit 28a7904

Please sign in to comment.