@eggjs/koa 3.1.0-beta.34 → 3.1.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.d.ts +113 -110
- package/dist/application.js +240 -281
- package/dist/context.d.ts +163 -159
- package/dist/context.js +296 -346
- package/dist/index.d.ts +6 -7
- package/dist/index.js +9 -6
- package/dist/request.d.ts +323 -319
- package/dist/request.js +451 -514
- package/dist/response.d.ts +214 -210
- package/dist/response.js +384 -468
- package/dist/types.d.ts +12 -9
- package/package.json +32 -37
- package/dist/types.js +0 -2
package/dist/application.d.ts
CHANGED
|
@@ -1,114 +1,117 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { Response } from "./response.js";
|
|
2
|
+
import { Request } from "./request.js";
|
|
3
|
+
import { AnyProto, CustomError } from "./types.js";
|
|
4
|
+
import { Context } from "./context.js";
|
|
5
|
+
import Emitter from "node:events";
|
|
6
|
+
import http, { IncomingMessage, ServerResponse } from "node:http";
|
|
7
|
+
import { HttpError } from "http-errors";
|
|
8
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
|
|
10
|
+
//#region src/application.d.ts
|
|
11
|
+
type ProtoImplClass<T = object> = new (...args: any[]) => T;
|
|
12
|
+
type Next = () => Promise<void>;
|
|
12
13
|
type _MiddlewareFunc<T> = (ctx: T, next: Next) => Promise<void> | void;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
type MiddlewareFunc<T extends Context = Context> = _MiddlewareFunc<T> & {
|
|
15
|
+
_name?: string;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
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
|
-
|
|
18
|
+
* Expose `Application` class.
|
|
19
|
+
* Inherits from `Emitter.prototype`.
|
|
20
|
+
*/
|
|
21
|
+
declare class Application extends Emitter {
|
|
22
|
+
[key: symbol]: unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Make HttpError available to consumers of the library so that consumers don't
|
|
25
|
+
* have a direct dependency upon `http-errors`
|
|
26
|
+
*/
|
|
27
|
+
static HttpError: typeof HttpError;
|
|
28
|
+
protected _proxy: boolean;
|
|
29
|
+
protected _env: string;
|
|
30
|
+
subdomainOffset: number;
|
|
31
|
+
proxyIpHeader: string;
|
|
32
|
+
maxIpsCount: number;
|
|
33
|
+
protected _keys?: string[];
|
|
34
|
+
middleware: MiddlewareFunc<Context>[];
|
|
35
|
+
ctxStorage: AsyncLocalStorage<Context>;
|
|
36
|
+
silent: boolean;
|
|
37
|
+
ContextClass: ProtoImplClass<Context>;
|
|
38
|
+
context: AnyProto;
|
|
39
|
+
RequestClass: ProtoImplClass<Request>;
|
|
40
|
+
request: AnyProto;
|
|
41
|
+
ResponseClass: ProtoImplClass<Response>;
|
|
42
|
+
response: AnyProto;
|
|
43
|
+
/**
|
|
44
|
+
* Initialize a new `Application`.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} [options] Application options
|
|
47
|
+
* @param {string} [options.env] Environment, default is `development`
|
|
48
|
+
* @param {string[]} [options.keys] Signed cookie keys
|
|
49
|
+
* @param {boolean} [options.proxy] Trust proxy headers
|
|
50
|
+
* @param {number} [options.subdomainOffset] Subdomain offset
|
|
51
|
+
* @param {string} [options.proxyIpHeader] Proxy IP header, defaults to X-Forwarded-For
|
|
52
|
+
* @param {number} [options.maxIpsCount] Max IPs read from proxy IP header, default to 0 (means infinity)
|
|
53
|
+
*/
|
|
54
|
+
constructor(options?: {
|
|
55
|
+
proxy?: boolean;
|
|
56
|
+
subdomainOffset?: number;
|
|
57
|
+
proxyIpHeader?: string;
|
|
58
|
+
maxIpsCount?: number;
|
|
59
|
+
env?: string;
|
|
60
|
+
keys?: string[];
|
|
61
|
+
});
|
|
62
|
+
get keys(): string[] | undefined;
|
|
63
|
+
set keys(value: string[] | undefined);
|
|
64
|
+
get env(): string;
|
|
65
|
+
set env(value: string);
|
|
66
|
+
get proxy(): boolean;
|
|
67
|
+
set proxy(value: boolean);
|
|
68
|
+
/**
|
|
69
|
+
* Shorthand for:
|
|
70
|
+
*
|
|
71
|
+
* http.createServer(app.callback()).listen(...)
|
|
72
|
+
*/
|
|
73
|
+
listen(...args: any[]): http.Server;
|
|
74
|
+
/**
|
|
75
|
+
* Return JSON representation.
|
|
76
|
+
* We only bother showing settings.
|
|
77
|
+
*/
|
|
78
|
+
toJSON(): object;
|
|
79
|
+
/**
|
|
80
|
+
* Inspect implementation.
|
|
81
|
+
*/
|
|
82
|
+
inspect(): object;
|
|
83
|
+
/**
|
|
84
|
+
* Use the given middleware `fn`.
|
|
85
|
+
*/
|
|
86
|
+
use<T extends Context = Context>(fn: MiddlewareFunc<T>): this;
|
|
87
|
+
/**
|
|
88
|
+
* Return a request handler callback
|
|
89
|
+
* for node's native http server.
|
|
90
|
+
*/
|
|
91
|
+
callback(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* return current context from async local storage
|
|
94
|
+
*/
|
|
95
|
+
get currentContext(): Context | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Handle request in callback.
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
protected handleRequest(ctx: Context, fnMiddleware: (ctx: Context) => Promise<void>): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Initialize a new context.
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
createContext(req: IncomingMessage, res: ServerResponse): Context;
|
|
106
|
+
/**
|
|
107
|
+
* Default error handler.
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
protected onerror(err: CustomError): void;
|
|
111
|
+
/**
|
|
112
|
+
* Response helper.
|
|
113
|
+
*/
|
|
114
|
+
protected _respond(ctx: Context): void;
|
|
114
115
|
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { Application, MiddlewareFunc, Next, ProtoImplClass };
|