@rspack/core 2.0.0-beta.5 → 2.0.0-beta.6
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/README.md +1 -1
- package/compiled/connect-next/index.d.ts +56 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +544 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/open/index.d.ts +161 -0
- package/compiled/open/package.json +1 -0
- package/dist/builtin-loader/swc/types.d.ts +9 -1
- package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +2 -2
- package/dist/checkNodeVersion.d.ts +1 -0
- package/dist/config/devServer.d.ts +96 -224
- package/dist/config/types.d.ts +2 -2
- package/dist/container/ContainerPlugin.d.ts +3 -2
- package/dist/container/ContainerReferencePlugin.d.ts +4 -3
- package/dist/container/ModuleFederationPlugin.d.ts +2 -1
- package/dist/container/ModuleFederationPluginV1.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +66 -37
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +2 -2
- package/dist/sharing/ConsumeSharedPlugin.d.ts +5 -5
- package/dist/sharing/ProvideSharedPlugin.d.ts +6 -5
- package/dist/sharing/SharePlugin.d.ts +9 -7
- package/hot/dev-server.js +1 -1
- package/hot/emitter.js +0 -2
- package/hot/log.js +0 -2
- package/hot/only-dev-server.js +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import * as http from 'node:http';
|
|
3
|
+
import { ListenOptions } from 'node:net';
|
|
4
|
+
|
|
5
|
+
/*!
|
|
6
|
+
* connect
|
|
7
|
+
* Copyright(c) 2010 Sencha Inc.
|
|
8
|
+
* Copyright(c) 2011 TJ Holowaychuk
|
|
9
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
10
|
+
* Copyright(c) 2025 Rstackjs
|
|
11
|
+
* MIT Licensed
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Public and internal Connect types.
|
|
16
|
+
*/
|
|
17
|
+
interface IncomingMessage extends http.IncomingMessage {
|
|
18
|
+
originalUrl?: http.IncomingMessage['url'] | undefined;
|
|
19
|
+
}
|
|
20
|
+
type NextFunction = (err?: any) => void;
|
|
21
|
+
type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void;
|
|
22
|
+
type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
|
|
23
|
+
type ErrorHandleFunction = (err: any, req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
|
|
24
|
+
type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
|
|
25
|
+
type ServerHandle = HandleFunction | http.Server;
|
|
26
|
+
interface ServerStackItem {
|
|
27
|
+
route: string;
|
|
28
|
+
handle: ServerHandle;
|
|
29
|
+
}
|
|
30
|
+
interface Server extends EventEmitter {
|
|
31
|
+
(req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
|
|
32
|
+
route: string;
|
|
33
|
+
stack: ServerStackItem[];
|
|
34
|
+
handle(req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
|
|
35
|
+
use(fn: NextHandleFunction): Server;
|
|
36
|
+
use(fn: HandleFunction): Server;
|
|
37
|
+
use(fn: http.Server): Server;
|
|
38
|
+
use(route: string, fn: NextHandleFunction): Server;
|
|
39
|
+
use(route: string, fn: HandleFunction): Server;
|
|
40
|
+
use(route: string, fn: http.Server): Server;
|
|
41
|
+
listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
|
|
42
|
+
listen(port: number, hostname?: string, callback?: Function): http.Server;
|
|
43
|
+
listen(path: string, callback?: Function): http.Server;
|
|
44
|
+
listen(options: ListenOptions, callback?: Function): http.Server;
|
|
45
|
+
listen(handle: unknown, listeningListener?: Function): http.Server;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a new connect server.
|
|
49
|
+
*
|
|
50
|
+
* @return {function}
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
declare function connect(): Server;
|
|
54
|
+
|
|
55
|
+
export { connect };
|
|
56
|
+
export type { ErrorHandleFunction, HandleFunction, IncomingMessage, NextFunction, NextHandleFunction, Server, ServerHandle, ServerStackItem, SimpleHandleFunction };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2010 Sencha Inc.
|
|
4
|
+
Copyright (c) 2011 LearnBoost
|
|
5
|
+
Copyright (c) 2011-2014 TJ Holowaychuk
|
|
6
|
+
Copyright (c) 2015 Douglas Christopher Wilson
|
|
7
|
+
Copyright (c) 2025 Rstackjs
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
10
|
+
a copy of this software and associated documentation files (the
|
|
11
|
+
'Software'), to deal in the Software without restriction, including
|
|
12
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
13
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
14
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
15
|
+
the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be
|
|
18
|
+
included in all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
21
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
22
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
23
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
24
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
25
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
26
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"connect-next","author":"TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)","version":"4.0.0","license":"MIT","types":"index.d.ts","type":"module"}
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as http from 'http';
|
|
3
|
+
import events from 'events';
|
|
4
|
+
import * as net from 'net';
|
|
5
|
+
import stream from 'stream';
|
|
6
|
+
import * as url from 'url';
|
|
7
|
+
|
|
8
|
+
interface ProxyTargetDetailed {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
protocol?: string | undefined;
|
|
12
|
+
hostname?: string | undefined;
|
|
13
|
+
socketPath?: string | undefined;
|
|
14
|
+
key?: string | undefined;
|
|
15
|
+
passphrase?: string | undefined;
|
|
16
|
+
pfx?: Buffer | string | undefined;
|
|
17
|
+
cert?: string | undefined;
|
|
18
|
+
ca?: string | undefined;
|
|
19
|
+
ciphers?: string | undefined;
|
|
20
|
+
secureProtocol?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>
|
|
24
|
+
extends events.EventEmitter
|
|
25
|
+
{
|
|
26
|
+
/**
|
|
27
|
+
* Creates the proxy server with specified options.
|
|
28
|
+
* @param options - Config object passed to the proxy
|
|
29
|
+
*/
|
|
30
|
+
constructor(options?: Server.ServerOptions);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Used for proxying regular HTTP(S) requests
|
|
34
|
+
* @param req - Client request.
|
|
35
|
+
* @param res - Client response.
|
|
36
|
+
* @param options - Additional options.
|
|
37
|
+
*/
|
|
38
|
+
web(
|
|
39
|
+
req: http.IncomingMessage,
|
|
40
|
+
res: http.ServerResponse,
|
|
41
|
+
options?: Server.ServerOptions,
|
|
42
|
+
callback?: Server.ErrorCallback,
|
|
43
|
+
): void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Used for proxying WS(S) requests
|
|
47
|
+
* @param req - Client request.
|
|
48
|
+
* @param socket - Client socket.
|
|
49
|
+
* @param head - Client head.
|
|
50
|
+
* @param options - Additionnal options.
|
|
51
|
+
*/
|
|
52
|
+
ws(
|
|
53
|
+
req: http.IncomingMessage,
|
|
54
|
+
socket: any,
|
|
55
|
+
head: any,
|
|
56
|
+
options?: Server.ServerOptions,
|
|
57
|
+
callback?: Server.ErrorCallback,
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A function that wraps the object in a webserver, for your convenience
|
|
62
|
+
* @param port - Port to listen on
|
|
63
|
+
* @param hostname - The hostname to listen on
|
|
64
|
+
*/
|
|
65
|
+
listen(port: number, hostname?: string): Server<TIncomingMessage, TServerResponse>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A function that closes the inner webserver and stops listening on given port
|
|
69
|
+
*/
|
|
70
|
+
close(callback?: () => void): void;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Creates the proxy server with specified options.
|
|
74
|
+
* @param options Config object passed to the proxy
|
|
75
|
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
76
|
+
*/
|
|
77
|
+
// tslint:disable:no-unnecessary-generics
|
|
78
|
+
static createProxyServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(
|
|
79
|
+
options?: Server.ServerOptions,
|
|
80
|
+
): Server<TIncomingMessage, TServerResponse>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Creates the proxy server with specified options.
|
|
84
|
+
* @param options Config object passed to the proxy
|
|
85
|
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
86
|
+
*/
|
|
87
|
+
// tslint:disable:no-unnecessary-generics
|
|
88
|
+
static createServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(
|
|
89
|
+
options?: Server.ServerOptions,
|
|
90
|
+
): Server<TIncomingMessage, TServerResponse>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Creates the proxy server with specified options.
|
|
94
|
+
* @param options Config object passed to the proxy
|
|
95
|
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
96
|
+
*/
|
|
97
|
+
// tslint:disable:no-unnecessary-generics
|
|
98
|
+
static createProxy<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(
|
|
99
|
+
options?: Server.ServerOptions,
|
|
100
|
+
): Server<TIncomingMessage, TServerResponse>;
|
|
101
|
+
|
|
102
|
+
addListener(event: string, listener: () => void): this;
|
|
103
|
+
on(event: string, listener: () => void): this;
|
|
104
|
+
on(event: "error", listener: Server.ErrorCallback<Error, TIncomingMessage, TServerResponse>): this;
|
|
105
|
+
on(event: "start", listener: Server.StartCallback<TIncomingMessage, TServerResponse>): this;
|
|
106
|
+
on(
|
|
107
|
+
event: "proxyReq",
|
|
108
|
+
listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>,
|
|
109
|
+
): this;
|
|
110
|
+
on(event: "proxyRes", listener: Server.ProxyResCallback<TIncomingMessage, TServerResponse>): this;
|
|
111
|
+
on(event: "proxyReqWs", listener: Server.ProxyReqWsCallback<http.ClientRequest, TIncomingMessage>): this;
|
|
112
|
+
on(event: "econnreset", listener: Server.EconnresetCallback<Error, TIncomingMessage, TServerResponse>): this;
|
|
113
|
+
on(event: "end", listener: Server.EndCallback<TIncomingMessage, TServerResponse>): this;
|
|
114
|
+
on(event: "open", listener: Server.OpenCallback): this;
|
|
115
|
+
on(event: "close", listener: Server.CloseCallback<TIncomingMessage>): this;
|
|
116
|
+
|
|
117
|
+
once(event: string, listener: () => void): this;
|
|
118
|
+
once(event: "error", listener: Server.ErrorCallback<Error, TIncomingMessage, TServerResponse>): this;
|
|
119
|
+
once(event: "start", listener: Server.StartCallback<TIncomingMessage, TServerResponse>): this;
|
|
120
|
+
once(
|
|
121
|
+
event: "proxyReq",
|
|
122
|
+
listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>,
|
|
123
|
+
): this;
|
|
124
|
+
once(event: "proxyRes", listener: Server.ProxyResCallback<TIncomingMessage, TServerResponse>): this;
|
|
125
|
+
once(event: "proxyReqWs", listener: Server.ProxyReqWsCallback<http.ClientRequest, TIncomingMessage>): this;
|
|
126
|
+
once(event: "econnreset", listener: Server.EconnresetCallback<Error, TIncomingMessage, TServerResponse>): this;
|
|
127
|
+
once(event: "end", listener: Server.EndCallback<TIncomingMessage, TServerResponse>): this;
|
|
128
|
+
once(event: "open", listener: Server.OpenCallback): this;
|
|
129
|
+
once(event: "close", listener: Server.CloseCallback<TIncomingMessage>): this;
|
|
130
|
+
removeListener(event: string, listener: () => void): this;
|
|
131
|
+
removeAllListeners(event?: string): this;
|
|
132
|
+
getMaxListeners(): number;
|
|
133
|
+
setMaxListeners(n: number): this;
|
|
134
|
+
listeners(event: string): Array<() => void>;
|
|
135
|
+
emit(event: string, ...args: any[]): boolean;
|
|
136
|
+
listenerCount(type: string): number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare namespace Server {
|
|
140
|
+
type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
|
|
141
|
+
type ProxyTargetUrl = string | Partial<url.Url>;
|
|
142
|
+
|
|
143
|
+
interface ServerOptions {
|
|
144
|
+
/** URL string to be parsed with the url module. */
|
|
145
|
+
target?: ProxyTarget | undefined;
|
|
146
|
+
/** URL string to be parsed with the url module. */
|
|
147
|
+
forward?: ProxyTargetUrl | undefined;
|
|
148
|
+
/** Object to be passed to http(s).request. */
|
|
149
|
+
agent?: any;
|
|
150
|
+
/** Object to be passed to https.createServer(). */
|
|
151
|
+
ssl?: any;
|
|
152
|
+
/** If you want to proxy websockets. */
|
|
153
|
+
ws?: boolean | undefined;
|
|
154
|
+
/** Adds x- forward headers. */
|
|
155
|
+
xfwd?: boolean | undefined;
|
|
156
|
+
/** Verify SSL certificate. */
|
|
157
|
+
secure?: boolean | undefined;
|
|
158
|
+
/** Explicitly specify if we are proxying to another proxy. */
|
|
159
|
+
toProxy?: boolean | undefined;
|
|
160
|
+
/** Specify whether you want to prepend the target's path to the proxy path. */
|
|
161
|
+
prependPath?: boolean | undefined;
|
|
162
|
+
/** Specify whether you want to ignore the proxy path of the incoming request. */
|
|
163
|
+
ignorePath?: boolean | undefined;
|
|
164
|
+
/** Local interface string to bind for outgoing connections. */
|
|
165
|
+
localAddress?: string | undefined;
|
|
166
|
+
/** Changes the origin of the host header to the target URL. */
|
|
167
|
+
changeOrigin?: boolean | undefined;
|
|
168
|
+
/** specify whether you want to keep letter case of response header key */
|
|
169
|
+
preserveHeaderKeyCase?: boolean | undefined;
|
|
170
|
+
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
|
|
171
|
+
auth?: string | undefined;
|
|
172
|
+
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
|
|
173
|
+
hostRewrite?: string | undefined;
|
|
174
|
+
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
|
|
175
|
+
autoRewrite?: boolean | undefined;
|
|
176
|
+
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
|
|
177
|
+
protocolRewrite?: string | undefined;
|
|
178
|
+
/** rewrites domain of set-cookie headers. */
|
|
179
|
+
cookieDomainRewrite?: false | string | { [oldDomain: string]: string } | undefined;
|
|
180
|
+
/** rewrites path of set-cookie headers. Default: false */
|
|
181
|
+
cookiePathRewrite?: false | string | { [oldPath: string]: string } | undefined;
|
|
182
|
+
/** object with extra headers to be added to target requests. */
|
|
183
|
+
headers?: { [header: string]: string } | undefined;
|
|
184
|
+
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
|
|
185
|
+
proxyTimeout?: number | undefined;
|
|
186
|
+
/** Timeout (in milliseconds) for incoming requests */
|
|
187
|
+
timeout?: number | undefined;
|
|
188
|
+
/** Specify whether you want to follow redirects. Default: false */
|
|
189
|
+
followRedirects?: boolean | undefined;
|
|
190
|
+
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
|
|
191
|
+
selfHandleResponse?: boolean | undefined;
|
|
192
|
+
/** Buffer */
|
|
193
|
+
buffer?: stream.Stream | undefined;
|
|
194
|
+
/** Explicitly set the method type of the ProxyReq */
|
|
195
|
+
method?: string | undefined;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
type StartCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = (
|
|
199
|
+
req: TIncomingMessage,
|
|
200
|
+
res: TServerResponse,
|
|
201
|
+
target: ProxyTargetUrl,
|
|
202
|
+
) => void;
|
|
203
|
+
type ProxyReqCallback<
|
|
204
|
+
TClientRequest = http.ClientRequest,
|
|
205
|
+
TIncomingMessage = http.IncomingMessage,
|
|
206
|
+
TServerResponse = http.ServerResponse,
|
|
207
|
+
> = (proxyReq: TClientRequest, req: TIncomingMessage, res: TServerResponse, options: ServerOptions) => void;
|
|
208
|
+
type ProxyResCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = (
|
|
209
|
+
proxyRes: TIncomingMessage,
|
|
210
|
+
req: TIncomingMessage,
|
|
211
|
+
res: TServerResponse,
|
|
212
|
+
) => void;
|
|
213
|
+
type ProxyReqWsCallback<TClientRequest = http.ClientRequest, TIncomingMessage = http.IncomingMessage> = (
|
|
214
|
+
proxyReq: TClientRequest,
|
|
215
|
+
req: TIncomingMessage,
|
|
216
|
+
socket: net.Socket,
|
|
217
|
+
options: ServerOptions,
|
|
218
|
+
head: any,
|
|
219
|
+
) => void;
|
|
220
|
+
type EconnresetCallback<
|
|
221
|
+
TError = Error,
|
|
222
|
+
TIncomingMessage = http.IncomingMessage,
|
|
223
|
+
TServerResponse = http.ServerResponse,
|
|
224
|
+
> = (
|
|
225
|
+
err: TError,
|
|
226
|
+
req: TIncomingMessage,
|
|
227
|
+
res: TServerResponse,
|
|
228
|
+
target: ProxyTargetUrl,
|
|
229
|
+
) => void;
|
|
230
|
+
type EndCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = (
|
|
231
|
+
req: TIncomingMessage,
|
|
232
|
+
res: TServerResponse,
|
|
233
|
+
proxyRes: TIncomingMessage,
|
|
234
|
+
) => void;
|
|
235
|
+
type OpenCallback = (proxySocket: net.Socket) => void;
|
|
236
|
+
type CloseCallback<TIncomingMessage = http.IncomingMessage> = (
|
|
237
|
+
proxyRes: TIncomingMessage,
|
|
238
|
+
proxySocket: net.Socket,
|
|
239
|
+
proxyHead: any,
|
|
240
|
+
) => void;
|
|
241
|
+
type ErrorCallback<TError = Error, TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> =
|
|
242
|
+
(
|
|
243
|
+
err: TError,
|
|
244
|
+
req: TIncomingMessage,
|
|
245
|
+
res: TServerResponse | net.Socket,
|
|
246
|
+
target?: ProxyTargetUrl,
|
|
247
|
+
) => void;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Based on definition by DefinitelyTyped:
|
|
252
|
+
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
type NextFunction<T = (err?: any) => void> = T;
|
|
256
|
+
interface RequestHandler<TReq = http.IncomingMessage, TRes = http.ServerResponse, TNext = NextFunction> {
|
|
257
|
+
(req: TReq, res: TRes, next?: TNext): Promise<void>;
|
|
258
|
+
upgrade: (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => void;
|
|
259
|
+
}
|
|
260
|
+
type Filter<TReq = http.IncomingMessage> = string | string[] | ((pathname: string, req: TReq) => boolean);
|
|
261
|
+
interface Plugin<TReq = http.IncomingMessage, TRes = http.ServerResponse> {
|
|
262
|
+
(proxyServer: Server<TReq, TRes>, options: Options<TReq, TRes>): void;
|
|
263
|
+
}
|
|
264
|
+
interface OnProxyEvent<TReq = http.IncomingMessage, TRes = http.ServerResponse> {
|
|
265
|
+
error?: Server.ErrorCallback<Error, TReq, TRes>;
|
|
266
|
+
proxyReq?: Server.ProxyReqCallback<http.ClientRequest, TReq, TRes>;
|
|
267
|
+
proxyReqWs?: Server.ProxyReqWsCallback<http.ClientRequest, TReq>;
|
|
268
|
+
proxyRes?: Server.ProxyResCallback<TReq, TRes>;
|
|
269
|
+
open?: Server.OpenCallback;
|
|
270
|
+
close?: Server.CloseCallback<TReq>;
|
|
271
|
+
start?: Server.StartCallback<TReq, TRes>;
|
|
272
|
+
end?: Server.EndCallback<TReq, TRes>;
|
|
273
|
+
econnreset?: Server.EconnresetCallback<Error, TReq, TRes>;
|
|
274
|
+
}
|
|
275
|
+
type Logger = Pick<Console, 'info' | 'warn' | 'error'>;
|
|
276
|
+
interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse> extends Server.ServerOptions {
|
|
277
|
+
/**
|
|
278
|
+
* Narrow down requests to proxy or not.
|
|
279
|
+
* Filter on {@link http.IncomingMessage.url `pathname`} which is relative to the proxy's "mounting" point in the server.
|
|
280
|
+
* Or use the {@link http.IncomingMessage `req`} object for more complex filtering.
|
|
281
|
+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathFilter.md
|
|
282
|
+
* @since v3.0.0
|
|
283
|
+
*/
|
|
284
|
+
pathFilter?: Filter<TReq>;
|
|
285
|
+
/**
|
|
286
|
+
* Modify request paths before requests are send to the target.
|
|
287
|
+
* @example
|
|
288
|
+
* ```js
|
|
289
|
+
* createProxyMiddleware({
|
|
290
|
+
* pathRewrite: {
|
|
291
|
+
* '^/api/old-path': '/api/new-path', // rewrite path
|
|
292
|
+
* }
|
|
293
|
+
* });
|
|
294
|
+
* ```
|
|
295
|
+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
|
|
296
|
+
*/
|
|
297
|
+
pathRewrite?: {
|
|
298
|
+
[regexp: string]: string;
|
|
299
|
+
} | ((path: string, req: TReq) => string | undefined) | ((path: string, req: TReq) => Promise<string>);
|
|
300
|
+
/**
|
|
301
|
+
* Access the internal http-proxy server instance to customize behavior
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```js
|
|
305
|
+
* createProxyMiddleware({
|
|
306
|
+
* plugins: [(proxyServer, options) => {
|
|
307
|
+
* proxyServer.on('error', (error, req, res) => {
|
|
308
|
+
* console.error(error);
|
|
309
|
+
* });
|
|
310
|
+
* }]
|
|
311
|
+
* });
|
|
312
|
+
* ```
|
|
313
|
+
* @link https://github.com/chimurai/http-proxy-middleware#plugins-array
|
|
314
|
+
* @since v3.0.0
|
|
315
|
+
*/
|
|
316
|
+
plugins?: Plugin<TReq, TRes>[];
|
|
317
|
+
/**
|
|
318
|
+
* Eject pre-configured plugins.
|
|
319
|
+
* NOTE: register your own error handlers to prevent server from crashing.
|
|
320
|
+
*
|
|
321
|
+
* @link https://github.com/chimurai/http-proxy-middleware#ejectplugins-boolean-default-false
|
|
322
|
+
* @since v3.0.0
|
|
323
|
+
*/
|
|
324
|
+
ejectPlugins?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Listen to http-proxy events
|
|
327
|
+
* @see {@link OnProxyEvent} for available events
|
|
328
|
+
* @example
|
|
329
|
+
* ```js
|
|
330
|
+
* createProxyMiddleware({
|
|
331
|
+
* on: {
|
|
332
|
+
* error: (error, req, res, target) => {
|
|
333
|
+
* console.error(error);
|
|
334
|
+
* }
|
|
335
|
+
* }
|
|
336
|
+
* });
|
|
337
|
+
* ```
|
|
338
|
+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/proxy-events.md
|
|
339
|
+
* @since v3.0.0
|
|
340
|
+
*/
|
|
341
|
+
on?: OnProxyEvent<TReq, TRes>;
|
|
342
|
+
/**
|
|
343
|
+
* Dynamically set the {@link Options.target `options.target`}.
|
|
344
|
+
* @example
|
|
345
|
+
* ```js
|
|
346
|
+
* createProxyMiddleware({
|
|
347
|
+
* router: async (req) => {
|
|
348
|
+
* return 'http://127:0.0.1:3000';
|
|
349
|
+
* }
|
|
350
|
+
* });
|
|
351
|
+
* ```
|
|
352
|
+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/router.md
|
|
353
|
+
*/
|
|
354
|
+
router?: {
|
|
355
|
+
[hostOrPath: string]: Server.ServerOptions['target'];
|
|
356
|
+
} | ((req: TReq) => Server.ServerOptions['target']) | ((req: TReq) => Promise<Server.ServerOptions['target']>);
|
|
357
|
+
/**
|
|
358
|
+
* Log information from http-proxy-middleware
|
|
359
|
+
* @example
|
|
360
|
+
* ```js
|
|
361
|
+
* createProxyMiddleware({
|
|
362
|
+
* logger: console
|
|
363
|
+
* });
|
|
364
|
+
* ```
|
|
365
|
+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
|
|
366
|
+
* @since v3.0.0
|
|
367
|
+
*/
|
|
368
|
+
logger?: Logger | any;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
declare function createProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse, TNext = NextFunction>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext>;
|
|
372
|
+
|
|
373
|
+
type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (buffer: Buffer, proxyRes: TReq, req: TReq, res: TRes) => Promise<Buffer | string>;
|
|
374
|
+
/**
|
|
375
|
+
* Intercept responses from upstream.
|
|
376
|
+
* Automatically decompress (deflate, gzip, brotli).
|
|
377
|
+
* Give developer the opportunity to modify intercepted Buffer and http.ServerResponse
|
|
378
|
+
*
|
|
379
|
+
* NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())
|
|
380
|
+
*/
|
|
381
|
+
declare function responseInterceptor<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(interceptor: Interceptor<TReq, TRes>): (proxyRes: TReq, req: TReq, res: TRes) => Promise<void>;
|
|
382
|
+
|
|
383
|
+
type BodyParserLikeRequest = http.IncomingMessage & {
|
|
384
|
+
body?: any;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Fix proxied body if bodyParser is involved.
|
|
388
|
+
*/
|
|
389
|
+
declare function fixRequestBody<TReq extends BodyParserLikeRequest = BodyParserLikeRequest>(proxyReq: http.ClientRequest, req: TReq): void;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Subscribe to {@link https://www.npmjs.com/package/http-proxy#listening-for-proxy-events http-proxy error events} to prevent server from crashing.
|
|
393
|
+
* Errors are logged with {@link https://www.npmjs.com/package/debug debug} library.
|
|
394
|
+
*/
|
|
395
|
+
declare const debugProxyErrorsPlugin: Plugin;
|
|
396
|
+
|
|
397
|
+
declare const errorResponsePlugin: Plugin;
|
|
398
|
+
|
|
399
|
+
declare const loggerPlugin: Plugin;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Implements option.on object to subscribe to http-proxy events.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```js
|
|
406
|
+
* createProxyMiddleware({
|
|
407
|
+
* on: {
|
|
408
|
+
* error: (error, req, res, target) => {},
|
|
409
|
+
* proxyReq: (proxyReq, req, res, options) => {},
|
|
410
|
+
* proxyReqWs: (proxyReq, req, socket, options) => {},
|
|
411
|
+
* proxyRes: (proxyRes, req, res) => {},
|
|
412
|
+
* open: (proxySocket) => {},
|
|
413
|
+
* close: (proxyRes, proxySocket, proxyHead) => {},
|
|
414
|
+
* start: (req, res, target) => {},
|
|
415
|
+
* end: (req, res, proxyRes) => {},
|
|
416
|
+
* econnreset: (error, req, res, target) => {},
|
|
417
|
+
* }
|
|
418
|
+
* });
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
declare const proxyEventsPlugin: Plugin;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @deprecated
|
|
425
|
+
*
|
|
426
|
+
* Will be removed in a future version.
|
|
427
|
+
*/
|
|
428
|
+
interface LegacyOptions<TReq = http.IncomingMessage, TRes = http.ServerResponse> extends Options<TReq, TRes> {
|
|
429
|
+
/**
|
|
430
|
+
* @deprecated
|
|
431
|
+
* Use `on.error` instead.
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```js
|
|
435
|
+
* {
|
|
436
|
+
* on: {
|
|
437
|
+
* error: () => {}
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
onError?: (...args: any[]) => void;
|
|
442
|
+
/**
|
|
443
|
+
* @deprecated
|
|
444
|
+
* Use `on.proxyRes` instead.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```js
|
|
448
|
+
* {
|
|
449
|
+
* on: {
|
|
450
|
+
* proxyRes: () => {}
|
|
451
|
+
* }
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
onProxyRes?: (...args: any[]) => void;
|
|
455
|
+
/**
|
|
456
|
+
* @deprecated
|
|
457
|
+
* Use `on.proxyReq` instead.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```js
|
|
461
|
+
* {
|
|
462
|
+
* on: {
|
|
463
|
+
* proxyReq: () => {}
|
|
464
|
+
* }
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
onProxyReq?: (...args: any[]) => void;
|
|
468
|
+
/**
|
|
469
|
+
* @deprecated
|
|
470
|
+
* Use `on.proxyReqWs` instead.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```js
|
|
474
|
+
* {
|
|
475
|
+
* on: {
|
|
476
|
+
* proxyReqWs: () => {}
|
|
477
|
+
* }
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
onProxyReqWs?: (...args: any[]) => void;
|
|
481
|
+
/**
|
|
482
|
+
* @deprecated
|
|
483
|
+
* Use `on.open` instead.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```js
|
|
487
|
+
* {
|
|
488
|
+
* on: {
|
|
489
|
+
* open: () => {}
|
|
490
|
+
* }
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
onOpen?: (...args: any[]) => void;
|
|
494
|
+
/**
|
|
495
|
+
* @deprecated
|
|
496
|
+
* Use `on.close` instead.
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ```js
|
|
500
|
+
* {
|
|
501
|
+
* on: {
|
|
502
|
+
* close: () => {}
|
|
503
|
+
* }
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
onClose?: (...args: any[]) => void;
|
|
507
|
+
/**
|
|
508
|
+
* @deprecated
|
|
509
|
+
* Use `logger` instead.
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* ```js
|
|
513
|
+
* {
|
|
514
|
+
* logger: console
|
|
515
|
+
* }
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
logProvider?: any;
|
|
519
|
+
/**
|
|
520
|
+
* @deprecated
|
|
521
|
+
* Use `logger` instead.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```js
|
|
525
|
+
* {
|
|
526
|
+
* logger: console
|
|
527
|
+
* }
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
logLevel?: any;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @deprecated
|
|
535
|
+
* This function is deprecated and will be removed in a future version.
|
|
536
|
+
*
|
|
537
|
+
* Use {@link createProxyMiddleware} instead.
|
|
538
|
+
*/
|
|
539
|
+
declare function legacyCreateProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse>(shortHand: string): RequestHandler<TReq, TRes>;
|
|
540
|
+
declare function legacyCreateProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse>(legacyOptions: LegacyOptions<TReq, TRes>): RequestHandler<TReq, TRes>;
|
|
541
|
+
declare function legacyCreateProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse>(legacyContext: Filter<TReq>, legacyOptions: LegacyOptions<TReq, TRes>): RequestHandler<TReq, TRes>;
|
|
542
|
+
|
|
543
|
+
export { createProxyMiddleware, debugProxyErrorsPlugin, errorResponsePlugin, fixRequestBody, legacyCreateProxyMiddleware, loggerPlugin, proxyEventsPlugin, responseInterceptor };
|
|
544
|
+
export type { Filter, LegacyOptions, Options, Plugin, RequestHandler };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Steven Chim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"http-proxy-middleware","author":"Steven Chim","version":"3.0.5","license":"MIT","types":"index.d.ts","type":"commonjs"}
|