///
import './node-polyfill-fetch';
import './node-polyfill-web-streams';
import type { Route } from './router';
import { CacheFs } from '../shared/lib/utils';
import type { MiddlewareManifest } from '../build/webpack/plugins/middleware-plugin';
import type RenderResult from './render-result';
import type { FetchEventResult } from './web/types';
import type { PrerenderManifest } from '../build';
import type { BaseNextRequest, BaseNextResponse } from './base-http';
import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin';
import type { PayloadOptions } from './send-payload';
import type { NextParsedUrlQuery, NextUrlWithParsedQuery } from './request-meta';
import type { Params } from '../shared/lib/router/utils/route-matcher';
import { IncomingMessage, ServerResponse } from 'http';
import { UrlWithParsedQuery } from 'url';
import { NodeNextRequest, NodeNextResponse } from './base-http/node';
import { ParsedUrlQuery } from 'querystring';
import { RenderOpts } from './render';
import { ParsedUrl } from '../shared/lib/router/utils/parse-url';
import BaseServer, { Options, FindComponentsResult, RoutingItem } from './base-server';
import { FontManifest } from './font-utils';
export * from './base-server';
export interface NodeRequestHandler {
(req: IncomingMessage | BaseNextRequest, res: ServerResponse | BaseNextResponse, parsedUrl?: NextUrlWithParsedQuery | undefined): Promise;
}
export default class NextNodeServer extends BaseServer {
private imageResponseCache?;
constructor(options: Options);
private compression;
protected loadEnvConfig({ dev }: {
dev: boolean;
}): void;
protected getPublicDir(): string;
protected getHasStaticDir(): boolean;
protected getPagesManifest(): PagesManifest | undefined;
protected getAppPathsManifest(): PagesManifest | undefined;
protected getBuildId(): string;
protected generateImageRoutes(): Route[];
protected generateStaticRoutes(): Route[];
protected setImmutableAssetCacheControl(res: BaseNextResponse): void;
protected generateFsStaticRoutes(): Route[];
protected generatePublicRoutes(): Route[];
private _validFilesystemPathSet;
protected getFilesystemPaths(): Set;
protected sendRenderResult(req: NodeNextRequest, res: NodeNextResponse, options: {
result: RenderResult;
type: 'html' | 'json';
generateEtags: boolean;
poweredByHeader: boolean;
options?: PayloadOptions | undefined;
}): Promise;
protected sendStatic(req: NodeNextRequest, res: NodeNextResponse, path: string): Promise;
protected handleCompression(req: NodeNextRequest, res: NodeNextResponse): void;
protected proxyRequest(req: NodeNextRequest, res: NodeNextResponse, parsedUrl: ParsedUrl): Promise<{
finished: boolean;
}>;
protected runApi(req: BaseNextRequest | NodeNextRequest, res: BaseNextResponse | NodeNextResponse, query: ParsedUrlQuery, params: Params | undefined, page: string, builtPagePath: string): Promise;
protected renderHTML(req: NodeNextRequest, res: NodeNextResponse, pathname: string, query: NextParsedUrlQuery, renderOpts: RenderOpts): Promise;
protected streamResponseChunk(res: NodeNextResponse, chunk: any): void;
protected imageOptimizer(req: NodeNextRequest, res: NodeNextResponse, paramsResult: import('./image-optimizer').ImageParamsResult): Promise<{
buffer: Buffer;
contentType: string;
maxAge: number;
}>;
protected getPagePath(pathname: string, locales?: string[]): string;
protected findPageComponents(pathname: string, query?: NextParsedUrlQuery, params?: Params | null, isAppDir?: boolean): Promise;
protected getFontManifest(): FontManifest;
protected getServerComponentManifest(): any;
protected getCacheFilesystem(): CacheFs;
private normalizeReq;
private normalizeRes;
getRequestHandler(): NodeRequestHandler;
render(req: BaseNextRequest | IncomingMessage, res: BaseNextResponse | ServerResponse, pathname: string, query?: NextParsedUrlQuery, parsedUrl?: NextUrlWithParsedQuery, internal?: boolean): Promise;
renderToHTML(req: BaseNextRequest | IncomingMessage, res: BaseNextResponse | ServerResponse, pathname: string, query?: ParsedUrlQuery): Promise;
renderError(err: Error | null, req: BaseNextRequest | IncomingMessage, res: BaseNextResponse | ServerResponse, pathname: string, query?: NextParsedUrlQuery, setHeaders?: boolean): Promise;
renderErrorToHTML(err: Error | null, req: BaseNextRequest | IncomingMessage, res: BaseNextResponse | ServerResponse, pathname: string, query?: ParsedUrlQuery): Promise;
render404(req: BaseNextRequest | IncomingMessage, res: BaseNextResponse | ServerResponse, parsedUrl?: NextUrlWithParsedQuery, setHeaders?: boolean): Promise;
serveStatic(req: BaseNextRequest | IncomingMessage, res: BaseNextResponse | ServerResponse, path: string, parsedUrl?: UrlWithParsedQuery): Promise;
protected getStaticRoutes(): Route[];
protected isServeableUrl(untrustedFileUrl: string): boolean;
protected generateRewrites({ restrictedRedirectPaths, }: {
restrictedRedirectPaths: string[];
}): {
beforeFiles: Route[];
afterFiles: Route[];
fallback: Route[];
};
protected getMiddlewareManifest(): MiddlewareManifest | null;
/**
* Return a list of middleware routing items. This method exists to be later
* overridden by the development server in order to use a different source
* to get the list.
*/
protected getMiddleware(): RoutingItem | undefined;
protected getEdgeFunctions(): RoutingItem[];
protected getEdgeRoutes(): RoutingItem[];
/**
* Get information for the edge function located in the provided page
* folder. If the edge function info can't be found it will throw
* an error.
*/
protected getEdgeFunctionInfo(params: {
page: string;
/** Whether we should look for a middleware or not */
middleware: boolean;
}): {
name: string;
paths: string[];
env: string[];
wasm: {
filePath: string;
name: string;
}[];
assets: {
filePath: string;
name: string;
}[];
} | null;
/**
* Checks if a middleware exists. This method is useful for the development
* server where we need to check the filesystem. Here we just check the
* middleware manifest.
*/
protected hasMiddleware(pathname: string): Promise;
/**
* A placeholder for a function to be defined in the development server.
* It will make sure that the root middleware or an edge function has been compiled
* so that we can run it.
*/
protected ensureMiddleware(): Promise;
protected ensureEdgeFunction(_pathname: string): Promise;
/**
* This method gets all middleware matchers and execute them when the request
* matches. It will make sure that each middleware exists and is compiled and
* ready to be invoked. The development server will decorate it to add warns
* and errors with rich traces.
*/
protected runMiddleware(params: {
request: BaseNextRequest;
response: BaseNextResponse;
parsedUrl: ParsedUrl;
parsed: UrlWithParsedQuery;
onWarning?: (warning: Error) => void;
}): Promise;
protected generateCatchAllMiddlewareRoute(devReady?: boolean): Route[];
private _cachedPreviewManifest;
protected getPrerenderManifest(): PrerenderManifest;
protected getRoutesManifest(): any;
protected attachRequestMeta(req: BaseNextRequest, parsedUrl: NextUrlWithParsedQuery): void;
protected runEdgeFunction(params: {
req: BaseNextRequest | NodeNextRequest;
res: BaseNextResponse | NodeNextResponse;
query: ParsedUrlQuery;
params: Params | undefined;
page: string;
onWarning?: (warning: Error) => void;
}): Promise;
}