Skip to content

Commit 0045dca

Browse files
committed
review
1 parent ba8056b commit 0045dca

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

packages/open-next/src/core/routing/cacheInterceptor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { createHash } from "node:crypto";
22

33
import { NextConfig, PrerenderManifest } from "config/index";
4-
import type { InternalEvent, InternalResult } from "types/open-next";
4+
import type {
5+
InternalEvent,
6+
InternalResult,
7+
MiddlewareEvent,
8+
} from "types/open-next";
59
import type { CacheValue } from "types/overrides";
610
import { emptyReadableStream, toReadableStream } from "utils/stream";
711

@@ -183,7 +187,7 @@ function decodePathParams(pathname: string): string {
183187
}
184188

185189
export async function cacheInterceptor(
186-
event: InternalEvent,
190+
event: MiddlewareEvent,
187191
): Promise<InternalEvent | InternalResult> {
188192
if (
189193
Boolean(event.headers["next-action"]) ||

packages/open-next/src/core/routing/middleware.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import {
66
NextConfig,
77
PrerenderManifest,
88
} from "config/index.js";
9-
import type { InternalEvent, InternalResult } from "types/open-next.js";
9+
import type {
10+
InternalEvent,
11+
InternalResult,
12+
MiddlewareEvent,
13+
} from "types/open-next.js";
1014
import { emptyReadableStream } from "utils/stream.js";
1115

1216
import { getQueryFromSearchParams } from "../../overrides/converters/utils.js";
@@ -28,12 +32,6 @@ const middleMatch = getMiddlewareMatch(
2832

2933
const REDIRECTS = new Set([301, 302, 303, 307, 308]);
3034

31-
type MiddlewareEvent = InternalEvent & {
32-
responseHeaders?: Record<string, string | string[]>;
33-
isExternalRewrite?: boolean;
34-
rewriteStatusCode?: number;
35-
};
36-
3735
type Middleware = (request: Request) => Response | Promise<Response>;
3836
type MiddlewareLoader = () => Promise<{ default: Middleware }>;
3937

packages/open-next/src/types/open-next.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export type InternalEvent = {
3434
readonly rewriteStatusCode?: number;
3535
} & BaseEventOrResult<"core">;
3636

37+
export type MiddlewareEvent = InternalEvent & {
38+
responseHeaders?: Record<string, string | string[]>;
39+
isExternalRewrite?: boolean;
40+
rewriteStatusCode?: number;
41+
};
42+
3743
export type InternalResult = {
3844
statusCode: number;
3945
headers: Record<string, string | string[]>;

0 commit comments

Comments
 (0)