silverwolf-x/project / packages /next /src /server /lib /router-utils /router-server-context.ts
silverwolf-x's picture
download
raw
2.36 kB
import type { IncomingMessage, ServerResponse } from 'node:http'
import type { NextConfigRuntime } from '../../config-shared'
import type { UrlWithParsedQuery } from 'node:url'
import type { ServerCacheStatus } from '../../../next-devtools/dev-overlay/cache-indicator'
import type { AnyStream } from '../../app-render/stream-ops'
export type RevalidateFn = (config: {
urlPath: string
headers: { [key: string]: string | string[] }
opts: { unstable_onlyGenerated?: boolean }
}) => Promise<void>
// The RouterServerContext contains instance specific
// information that isn't available/relevant when
// deployed in serverless environments, the key is
// the relative project dir this allows separate contexts
// when running multiple next instances in same process
export type RouterServerContext = Record<
string,
{
// hostname the server is started with
hostname?: string
// revalidate function to bypass going through network
// to invoke revalidate request (uses mocked req/res)
revalidate?: RevalidateFn
// function to render the 404 page
render404?: (
req: IncomingMessage,
res: ServerResponse,
parsedUrl?: UrlWithParsedQuery,
setHeaders?: boolean
) => Promise<void>
// exposing nextConfig for dev mode specifically
nextConfig?: NextConfigRuntime
// whether running in custom server mode
isCustomServer?: boolean
// whether test proxy is enabled
experimentalTestProxy?: boolean
// allow dev server to log with original stack
logErrorWithOriginalStack?: (err: unknown, type: string) => void
// allow setting ISR status in dev
setIsrStatus?: (key: string, value: boolean | undefined) => void
setReactDebugChannel?: (
debugChannel: { readable: AnyStream },
htmlRequestId: string,
requestId: string
) => void
setCacheStatus?: (status: ServerCacheStatus, htmlRequestId: string) => void
sendErrorsToBrowser?: (
errorsRscStream: AnyStream,
htmlRequestId: string
) => void
// indicates request handlers are already wrapped by next-server tracing
isWrappedByNextServer?: boolean
}
>
export const RouterServerContextSymbol = Symbol.for(
'@next/router-server-methods'
)
export const routerServerGlobal = globalThis as typeof globalThis & {
[RouterServerContextSymbol]?: RouterServerContext
}

Xet Storage Details

Size:
2.36 kB
·
Xet hash:
3ef552945cf2c058dc2c5bacc764b6384fd912132917b9e93128ed84d16e38d5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.