Skip to content

mitm-core / IProxy

Interface: IProxy ​

Defined in: src/lib/Proxy.ts:29

Interface for the Proxy class, managing plugin execution, HTTP server events, and lifecycle management.

Methods ​

listen() ​

listen(port, callback?): Promise<void>

Defined in: src/lib/Proxy.ts:57

Starts the proxy's HTTP server.

Parameters ​

port ​

number

Port to listen on. Use 0 to request an available port.

callback? ​

() => void | Promise<void>

Optional callback invoked after the server starts.

Returns ​

Promise<void>

A promise representing startup.


stop() ​

stop(shutdownTimeoutMs?): Promise<void>

Defined in: src/lib/Proxy.ts:67

Gracefully shuts down the proxy, allowing active requests to drain until the shutdown timeout expires before forcing cleanup.

Parameters ​

shutdownTimeoutMs? ​

number

Maximum time to wait for active requests. Defaults to 1500 ms.

Returns ​

Promise<void>

A promise that resolves when shutdown completes.


unuse() ​

unuse(plugin): this

Defined in: src/lib/Proxy.ts:48

Unregisters a plugin before the proxy starts. Does nothing if the plugin is not registered.

Parameters ​

plugin ​

BasePlugin<any>

Plugin to unregister.

Returns ​

this

The current proxy instance for chaining.

Throws ​

If the proxy is starting, running, or has been stopped.


use() ​

use<K>(plugin): this

Defined in: src/lib/Proxy.ts:38

Registers a plugin before the proxy starts. Duplicate registration of the same plugin instance is ignored.

Type Parameters ​

K ​

K extends keyof PluginEventMap

Parameters ​

plugin ​

BasePlugin<K>

Plugin to register.

Returns ​

this

The current proxy instance for chaining.

Throws ​

If the proxy is starting, running, or has been stopped.