-
Notifications
You must be signed in to change notification settings - Fork 568
/
interface.ts
144 lines (137 loc) 路 3.65 KB
/
interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { Context as EggContext, Application as EggApplication } from 'egg';
import {
IMidwayContainer,
IMidwayContext,
IMidwayApplication,
IConfigurationOptions,
NextFunction as BaseNextFunction,
} from '@midwayjs/core';
import { DefaultState, Middleware } from 'koa';
import { ILogger, LoggerOptions } from '@midwayjs/logger';
import { IParseOptions } from 'qs';
export const RUN_IN_AGENT_KEY = 'egg:run_in_agent';
export const EGG_AGENT_APP_KEY = 'egg_agent_app';
export interface State extends DefaultState {}
export interface IMidwayWebBaseApplication {
applicationContext: IMidwayContainer;
getLogger(name?: string): ILogger;
getCoreLogger(): ILogger;
generateMiddleware?(middlewareId: any): Promise<Middleware<State, EggContext>>;
createLogger(name: string, options: LoggerOptions): ILogger;
}
/**
* @deprecated since version 3.0.0
* Please use Application from '@midwayjs/web'
*/
export type IMidwayWebApplication = IMidwayApplication<Context, EggApplication & IMidwayWebBaseApplication>;
export interface Application extends IMidwayWebApplication {}
/**
* @deprecated since version 3.0.0
* Please use Context from '@midwayjs/web'
*/
export type IMidwayWebContext <ResponseBodyT = unknown> = IMidwayContext<EggContext<ResponseBodyT>>;
export interface Context <ResponseBodyT = unknown> extends IMidwayWebContext <ResponseBodyT> {
session: {
/**
* JSON representation of the session.
*/
toJSON(): object;
/**
* Return how many values there are in the session object.
* Used to see if it"s "populated".
*/
readonly length: number;
/**
* populated flag, which is just a boolean alias of .length.
*/
readonly populated: boolean;
/**
* get/set session maxAge
*/
maxAge: number | 'session' | undefined;
/**
* commit this session's headers if autoCommit is set to false.
*/
manuallyCommit(): Promise<void>;
/**
* save this session no matter whether it is populated
*/
save(): void;
/**
* allow to put any value on session object
*/
[_: string]: any;
};
state: State;
}
/**
* @deprecated since version 3.0.0
* Please use NextFunction from '@midwayjs/web'
*/
export type IMidwayWebNext = BaseNextFunction;
export type NextFunction = BaseNextFunction;
export interface IMidwayWebConfigurationOptions extends IConfigurationOptions {
app?: IMidwayWebApplication;
plugins?: {
[plugin: string]: {
enable: boolean;
path?: string;
package?: string;
}
};
typescript?: boolean;
processType?: 'application' | 'agent';
globalConfig?: any;
/**
* application http port
*/
port?: number;
/**
* application hostname, 127.0.0.1 as default
*/
hostname?: string;
/**
* https key
*/
key?: string | Buffer | Array<Buffer | Object>;
/**
* https cert
*/
cert?: string | Buffer | Array<string | Buffer>;
/**
* https ca
*/
ca?: string | Buffer | Array<string | Buffer>;
/**
* http2 support
*/
http2?: boolean;
/**
* http global prefix
*/
globalPrefix?: string;
/**
* http query parser mode, default is extended
*/
queryParseMode?: 'simple' | 'extended';
/**
* http query parse options, used when 'simple' mode is used
*/
queryParseOptions?: IParseOptions;
/**
* https/https/http2 server options
*/
serverOptions?: Record<string, any>;
}
/**
* @deprecated since version 3.0.0
* Please use IMiddleware from '@midwayjs/core'
*/
export type MidwayWebMiddleware = Middleware<State, Context>;
/**
* @deprecated since version 3.0.0
* Please use IMiddleware from '@midwayjs/core'
*/
export interface IWebMiddleware {
resolve(): MidwayWebMiddleware;
}