UNPKG

1.98 kBPlain TextView Raw
1import Koa = require("koa");
2import {
3 IException
4} from "./Exception";
5
6export interface IParams {
7 ROOT_PATH: string;
8 port: string | number;
9 isSingle: boolean;
10}
11export interface IApps {
12 [index: string]: IApp;
13}
14export interface IApp {
15 router?: any;
16 name?: string;
17 class?: any;
18 path?: string;
19}
20export interface IPlugin {
21 enable: string;
22 path?: string;
23 package?: string;
24}
25export interface IPlugins {
26 [index: string]: IPlugin;
27}
28
29export interface ILoaderParams {
30 keypath?: string;
31 path: string;
32 context?: any;
33 type?: string;
34 ignore?: string[];
35 isRequired?: boolean;
36 isGetMap?: boolean;
37}
38
39export interface IGlobalPath {
40 readonly ROOT_PATH: string;
41 readonly LOG_PATH: string;
42 readonly CONF_PATH: string;
43 readonly PLUGINS_PATH: string;
44 readonly APP_PATH: string;
45 readonly LIB_PATH: string;
46 readonly TPL_PATH: string;
47 readonly STATIC_PATH: string;
48 readonly MODULES_PATH: string;
49}
50export interface IGlobalModuleMap {
51 [key: string]: string;
52}
53export type IGetFuncName = (path: string, keypath: string) => string;
54export type ILoaderFunc = (obj: ILoaderParams) => void;
55export type IGetGlobalModule = (loadList: any, appName?: string) => void;
56export type IGetGlobalModuleByPath = (loaderItem: ILoaderParams, appName?: string) => IGlobalModuleMap;
57export interface ILoader {
58 getFuncName: IGetFuncName;
59 loader: ILoaderFunc;
60 getGlobalModule: IGetGlobalModule;
61 getGlobalModuleByPath: IGetGlobalModuleByPath;
62}
63export type IRenderHtml = (_view: string, locals: any) => Promise<any>;
64export type IRender = (_view: string, locals: any) => Promise<any>;
65export interface IContext extends Koa.Context {
66 bun: IContextUtil;
67 renderHtml: IRenderHtml;
68 render: IRender;
69}
70export interface IContextUtil {
71 Loader: ILoader;
72 Logger: any;
73 globalPath: IGlobalPath;
74 isSingle: boolean;
75 app: IApps | IApp;
76 Exception: typeof IException;
77}