// Type definitions for next 2.4 // Project: https://github.com/zeit/next.js // Definitions by: Drew Hays // Brice BERNARD // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 /// import * as http from "http"; import * as url from "url"; declare namespace next { type UrlLike = url.UrlObject | url.Url; interface ServerConfig { // known keys webpack?: any; webpackDevMiddleware?: any; poweredByHeader?: boolean; distDir?: string; assetPrefix?: string; configOrigin?: string; useFileSystemPublicRoutes?: boolean; // and since this is a config, it can take anything else, too. [key: string]: any; } interface ServerOptions { dir?: string; dev?: boolean; staticMarkup?: boolean; quiet?: boolean; conf?: ServerConfig; } interface Server { handleRequest( req: http.IncomingMessage, res: http.ServerResponse, parsedUrl?: UrlLike, ): Promise; getRequestHandler(): ( req: http.IncomingMessage, res: http.ServerResponse, parsedUrl?: UrlLike, ) => Promise; prepare(): Promise; close(): Promise; defineRoutes(): Promise; start(): Promise; run( req: http.IncomingMessage, res: http.ServerResponse, parsedUrl: UrlLike, ): Promise; render( req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: { [key: string]: | boolean | boolean[] | number | number[] | string | string[]; }, parsedUrl?: UrlLike, ): Promise; renderError( err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: { [key: string]: | boolean | boolean[] | number | number[] | string | string[]; }, ): Promise; render404( req: http.IncomingMessage, res: http.ServerResponse, parsedUrl: UrlLike, ): Promise; renderToHTML( req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: { [key: string]: | boolean | boolean[] | number | number[] | string | string[]; }, ): Promise; renderErrorToHTML( err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: { [key: string]: | boolean | boolean[] | number | number[] | string | string[]; }, ): Promise; serveStatic( req: http.IncomingMessage, res: http.ServerResponse, path: string, ): Promise; isServeableUrl(path: string): boolean; isInternalUrl(req: http.IncomingMessage): boolean; readBuildId(): string; handleBuildId(buildId: string, res: http.ServerResponse): boolean; getCompilationError( page: string, req: http.IncomingMessage, res: http.ServerResponse, ): Promise; handleBuildHash( filename: string, hash: string, res: http.ServerResponse, ): void; send404(res: http.ServerResponse): void; } } declare function next(options?: next.ServerOptions): next.Server; export = next;