@joker.front/cli
Version:
The Next-Generation Front-End Toolchain: Swift, Efficient, and Adaptive.
66 lines (65 loc) • 1.85 kB
TypeScript
import type { ServerOptions as HttpsServerOptions } from "node:https";
import Connect from "connect";
import http, { OutgoingHttpHeaders } from "node:http";
import type { CorsOptions } from "cors";
import type * as net from "node:net";
import { ProxyOptions } from "./middlewares/proxy";
import type { SourceMap } from "rollup";
export type SendOptions = {
etag?: string;
cacheControl?: string;
headers?: http.OutgoingHttpHeaders;
map?: SourceMap | null;
};
export type HttpServerOptions = {
/** 服务端口 */
port?: number;
/** 服务hostName */
host?: string;
/**
* 是否打开浏览器,可设置自定义打开的地址
*/
open?: boolean | string;
/**
* 是否启用https,https的配置
*/
https?: boolean | HttpsServerOptions;
/**
* 跨域处理配置
*/
cors?: boolean | CorsOptions;
headers?: OutgoingHttpHeaders;
/**
* 请求代理配置
*/
proxy?: Record<string, string | ProxyOptions>;
};
type HostName = {
host: string;
name: string;
};
export declare class HttpServer {
private config;
private basePath?;
server: http.Server;
app: Connect.Server;
hostName?: HostName;
sockets: Set<net.Socket>;
hasListened: boolean;
private customPort;
resolveUrls: {
local: string[];
network: string[];
};
constructor(config?: HttpServerOptions, basePath?: string | undefined);
start(): Promise<void>;
resolveServerUrls(): Promise<void>;
send(req: http.IncomingMessage, res: http.ServerResponse, content: string | Buffer, type: string, options?: SendOptions): void;
close(): Promise<void>;
printServerUrls(): void;
private initHandler;
private initDefaultValue;
private resolveHttpsServerConfig;
private readHttpsCertContent;
}
export {};