@zenweb/core
Version:
ZenWeb Core Module - Module loader and Server
78 lines (77 loc) • 1.76 kB
TypeScript
import { Server } from 'node:http';
import { Application, CoreOption, LoadedModule, SetupFunction, SetupOption } from './types.js';
export declare class Core {
/**
* 取得应用名称
* 获取顺序: env.APP_NAME || hostname
*/
readonly name: string;
/**
* 启动时间: 毫秒时间戳
*/
readonly startTime: number;
/**
* 取得 Koa 实例
*/
readonly app: Application;
/**
* 已载入的模块
*/
readonly loadedModules: LoadedModule[];
/**
* 取得 http.Server 实例
*/
readonly server: Server;
/**
* core debug 信息打印
*/
readonly debug: import("./util.js").Debugger;
/**
* 应用是否正在停止中
*/
private _stopping;
/**
* 当前已加载模块顺序值
*/
private _orderIndex;
constructor(option?: CoreOption);
/**
* 安装模块
* @param setup 模块模块安装函数
* @param opt 安装选项
*/
setup(setup: SetupFunction, opt?: SetupOption): this;
/**
* 检查模块是否存在
* @param name 模块名称
*/
moduleExists(name: string): boolean;
/**
* 取得已排序的模块列表
*/
getOrderedModules(): LoadedModule[];
/**
* 启动所有模块代码
*/
boot(): Promise<this>;
/**
* 监听端口,默认 7001
*/
listen(port?: number): Promise<void>;
/**
* 关闭端口监听
*/
closeListen(): Promise<void>;
/**
* 启动应用
*/
start(port?: number): Promise<void>;
/**
* 进程型号接收处理
*/
private _signalReceiver;
/**
* 停止应用
*/
stop(signal?: string | number): Promise<void>;
}