1 | import Koa = require("koa");
|
2 | import {
|
3 | IException
|
4 | } from "./Exception";
|
5 |
|
6 | export interface IParams {
|
7 | ROOT_PATH: string;
|
8 | port: string | number;
|
9 | isSingle: boolean;
|
10 | }
|
11 | export interface IApps {
|
12 | [index: string]: IApp;
|
13 | }
|
14 | export interface IApp {
|
15 | router?: any;
|
16 | name?: string;
|
17 | class?: any;
|
18 | path?: string;
|
19 | }
|
20 | export interface IPlugin {
|
21 | enable: string;
|
22 | path?: string;
|
23 | package?: string;
|
24 | }
|
25 | export interface IPlugins {
|
26 | [index: string]: IPlugin;
|
27 | }
|
28 |
|
29 | export 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 |
|
39 | export 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 | }
|
50 | export interface IGlobalModuleMap {
|
51 | [key: string]: string;
|
52 | }
|
53 | export type IGetFuncName = (path: string, keypath: string) => string;
|
54 | export type ILoaderFunc = (obj: ILoaderParams) => void;
|
55 | export type IGetGlobalModule = (loadList: any, appName?: string) => void;
|
56 | export type IGetGlobalModuleByPath = (loaderItem: ILoaderParams, appName?: string) => IGlobalModuleMap;
|
57 | export interface ILoader {
|
58 | getFuncName: IGetFuncName;
|
59 | loader: ILoaderFunc;
|
60 | getGlobalModule: IGetGlobalModule;
|
61 | getGlobalModuleByPath: IGetGlobalModuleByPath;
|
62 | }
|
63 | export type IRenderHtml = (_view: string, locals: any) => Promise<any>;
|
64 | export type IRender = (_view: string, locals: any) => Promise<any>;
|
65 | export interface IContext extends Koa.Context {
|
66 | bun: IContextUtil;
|
67 | renderHtml: IRenderHtml;
|
68 | render: IRender;
|
69 | }
|
70 | export interface IContextUtil {
|
71 | Loader: ILoader;
|
72 | Logger: any;
|
73 | globalPath: IGlobalPath;
|
74 | isSingle: boolean;
|
75 | app: IApps | IApp;
|
76 | Exception: typeof IException;
|
77 | }
|