import Koa from 'koa'; import { IConstructor } from './base'; /** * ## Base Framework Application * * @author Big Mogician * @export * @interface IBaseApplication * @extends {Koa} * @template F */ export interface IBaseApplication extends Koa { config: F; } /** * ## Base Framework Context * * @author Big Mogician * @export * @interface IBaseContext * @extends {Koa.Context} * @template F * @template A */ export interface IBaseContext> extends Koa.Context { app: A; config: F; request: Koa.Request & { body: any; }; } /** * ## Inner Framework Application * * @author Big Mogician * @export * @interface IInnerApplication * @extends {IBaseApplication} * @template F */ export interface IInnerApplication extends IBaseApplication { ROOT_PATH: string; ROOT_NAME: string; NODE_ENV: string; MODE_AE: boolean; libs: PureObject; controllers: PureObject>>; services: PureObject>>; middlewares: PureObject; middlewareQueue: PriorityDefine[]; middlewareConfig: PureObject; routers: any[]; versionMap: PureObject; pkg: PureObject; fns: PureObject; fnConfig: PureObject; } export declare type MiddlewareFactory = (options: OPTS, app: APP) => (ctx: any, next: () => Promise) => Promise; export declare type NormalizedMiddleware = (ctx: T, next: () => Promise) => Promise; export interface IDir { baseDir: string; type: 'app' | 'framework' | 'plugin'; name: string; } export interface IAstroboyOptions { NODE_ENV: string; NODE_PORT: string; ROOT_PATH: string; PROXY: boolean; MODE_AE?: boolean; } export interface ILoaderOptions { dirs: IDir[]; config: F; app: A; } export interface ICoreLoaderOptions> extends ILoaderOptions { astroboy?: any; } export interface IPluginEntry { path?: string; package?: string; name?: string; } export declare type PriorityDefine = PathIgnoreOptions & { priority: number; name: string; enable?: boolean; }; export declare type ValidOperator = string | RegExp | ((context: T) => boolean); export declare type ValidOperators = ValidOperator[]; export interface IDefaultLoaders { loaderPattern: string; pluginPattern: string; loaderConfigPattern: string; } export interface IPathMatchOptions extends ITrueOptions { match: ValidOperator | ValidOperators; } export interface IPathIgnoreOptions extends ITrueOptions { ignore: ValidOperator | ValidOperators; } export interface ITrueOptions { options: OPT; } export declare type PathIgnoreOptions = Partial | IPathIgnoreOptions | ITrueOptions>; export declare type PureObject = { [prop: string]: T; };