diff --git a/packages/next/src/server/next.ts b/packages/next/src/server/next.ts index 86986d761bf7c..4c6e7e2010842 100644 --- a/packages/next/src/server/next.ts +++ b/packages/next/src/server/next.ts @@ -6,7 +6,9 @@ import type { import type { UrlWithParsedQuery } from 'url' import type { IncomingMessage, ServerResponse } from 'http' import type { Duplex } from 'stream' -import type { NextUrlWithParsedQuery } from './request-meta' +import type { NextParsedUrlQuery, NextUrlWithParsedQuery } from './request-meta' +import type { ParsedUrlQuery } from 'querystring' +import type { WorkerRequestHandler, WorkerUpgradeHandler } from './lib/types' import './require-hook' import './node-polyfill-crypto' @@ -57,7 +59,7 @@ export type UpgradeHandler = ( const SYMBOL_LOAD_CONFIG = Symbol('next.load_config') -interface NextWrapperServer { +interface NextWrapperServer extends LegacyServerMethods { // NOTE: the methods/properties here are the public API for custom servers. // Consider backwards compatibilty when changing something here! @@ -72,30 +74,74 @@ interface NextWrapperServer { // used internally getUpgradeHandler(): UpgradeHandler +} - // legacy methods that we left exposed in the past - - logError(...args: Parameters): void - +interface LegacyServerMethods { + /** + * This method is only public for backwards compatibility, and may change or be removed in a future release. + * @deprecated + */ + logError(err: Error): void + + /** + * This method is only public for backwards compatibility, and may change or be removed in a future release. + * @deprecated + */ render( - ...args: Parameters - ): ReturnType - + req: IncomingMessage, + res: ServerResponse, + pathname: string, + query?: NextParsedUrlQuery, + parsedUrl?: NextUrlWithParsedQuery, + internal?: boolean + ): Promise + + /** + * This method is only public for backwards compatibility, and may change or be removed in a future release. + * @deprecated + */ renderToHTML( - ...args: Parameters - ): ReturnType - + req: IncomingMessage, + res: ServerResponse, + pathname: string, + query?: ParsedUrlQuery + ): Promise + + /** + * This method is only public for backwards compatibility, and may change or be removed in a future release. + * @deprecated + */ renderError( - ...args: Parameters - ): ReturnType - + err: Error | null, + req: IncomingMessage, + res: ServerResponse, + pathname: string, + query?: NextParsedUrlQuery, + setHeaders?: boolean + ): Promise + + /** + * This method is only public for backwards compatibility, and may change or be removed in a future release. + * @deprecated + */ renderErrorToHTML( - ...args: Parameters - ): ReturnType - + err: Error | null, + req: IncomingMessage, + res: ServerResponse, + pathname: string, + query?: ParsedUrlQuery + ): Promise + + /** + * This method is only public for backwards compatibility, and may change or be removed in a future release. + * @deprecated + */ render404( - ...args: Parameters - ): ReturnType + req: IncomingMessage, + res: ServerResponse, + parsedUrl?: NextUrlWithParsedQuery, + setHeaders?: boolean + ): Promise } /** The wrapper server used by `next start` */