@@ -85,14 +85,31 @@ export interface ServerOptions {
8585}
8686
8787export class ProxyServer extends EventEmitter {
88+ /**
89+ * Used for proxying WS(S) requests
90+ * @param req - Client request.
91+ * @param socket - Client socket.
92+ * @param head - Client head.
93+ * @param options - Additional options.
94+ */
8895 public readonly ws ;
96+ /**
97+ * Used for proxying regular HTTP(S) requests
98+ * @param req - Client request.
99+ * @param res - Client response.
100+ * @param options - Additional options.
101+ */
89102 public readonly web ;
90103
91104 private options : ServerOptions ;
92105 private webPasses ;
93106 private wsPasses ;
94107 private _server ?;
95108
109+ /**
110+ * Creates the proxy server with specified options.
111+ * @param options - Config object passed to the proxy
112+ */
96113 constructor ( options : ServerOptions = { } ) {
97114 super ( ) ;
98115 log ( "creating a ProxyServer" , options ) ;
@@ -187,6 +204,11 @@ export class ProxyServer extends EventEmitter {
187204 }
188205 } ;
189206
207+ /**
208+ * A function that wraps the object in a webserver, for your convenience
209+ * @param port - Port to listen on
210+ * @param hostname - The hostname to listen on
211+ */
190212 listen = ( port : number , hostname ?: string ) => {
191213 log ( "listen" , { port, hostname } ) ;
192214
@@ -210,6 +232,9 @@ export class ProxyServer extends EventEmitter {
210232 return this . _server ?. address ( ) ;
211233 } ;
212234
235+ /**
236+ * A function that closes the inner webserver and stops listening on given port
237+ */
213238 close = ( cb ?: Function ) => {
214239 if ( this . _server == null ) {
215240 cb ?.( ) ;
0 commit comments