// Type definitions for next-server 8.1 // Project: https://github.com/zeit/next.js/packages/next-server // Definitions by: Drew Hays // Brice BERNARD // James Hegedus // Resi Respati // Scott Jones // Joao Vieira // AJ Livingston // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 /// import * as http from "http"; import { NextConfig } from "./next-config"; import { UrlLike, DefaultQuery } from "./router"; declare namespace next { interface RenderOptions { staticMarkup: boolean; distDir: string; buildId: string; generateETags: boolean; runtimeConfig?: Record; } /** * Options passed to the Server constructor in Node.js. */ interface ServerOptions { dev?: boolean; dir?: string; staticMarkup?: boolean; quiet?: boolean; conf?: NextConfig; } interface ServerRoute

{ match(pathname: string, params?: Partial

): P | false; fn(req: http.IncomingMessage, res: http.ServerResponse, params: P, parsedUrl: UrlLike): Promise; } interface ServerRouter { routes: ServerRoute[]; add(route: ServerRoute): void; match(req: http.IncomingMessage, res: http.ServerResponse, parsedUrl: UrlLike): (() => Promise) | undefined; } /** * Next.js server instance API. */ interface Server { dir: string; quiet: boolean; router: ServerRouter; nextConfig: NextConfig; distDir: string; buildId: string; renderOpts: RenderOptions; currentPhase(): string; handleRequest( req: http.IncomingMessage, res: http.ServerResponse, parsedUrl?: UrlLike ): Promise; getRequestHandler(): ( req: http.IncomingMessage, res: http.ServerResponse, parsedUrl?: UrlLike ) => Promise; setAssetPrefix(prefix: string): void; prepare(): Promise; close(): Promise; setImmutableAssetCacheControl(res: http.ServerResponse): void; generateRoutes(): ServerRoute[]; run(req: http.IncomingMessage, res: http.ServerResponse, parsedUrl: UrlLike): Promise; render( req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: DefaultQuery, parsedUrl?: UrlLike ): Promise; renderToHTML( req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: DefaultQuery ): Promise; renderError( err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: DefaultQuery ): Promise; renderErrorToHTML( err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: DefaultQuery ): Promise; render404( req: http.IncomingMessage, res: http.ServerResponse, parsedUrl?: UrlLike ): Promise; serveStatic( req: http.IncomingMessage, res: http.ServerResponse, path: string ): Promise; isServeableUrl(path: string): boolean; readBuildId(): string; } } declare function next(options?: next.ServerOptions): next.Server; export = next;