UNPKG

rex-server

Version:

Rex Server is a Node.js-based reverse proxy server available as an npm package. It allows you to handle HTTP and HTTPS traffic, route requests to upstream servers, and manage worker processes efficiently. With its CLI interface, Rex makes it easy to confi

39 lines (38 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProxyURL = void 0; const url_1 = require("url"); /** * A class that extends the native `URL` class to represent a proxy URL with an optional path. * * This class extends the `URL` class to provide a more specific implementation for handling proxy URLs, * with an optional path parameter that can be included in the URL construction. * * The `urlString` property holds the base URL string that was provided during construction, and the class * allows manipulation of the URL using standard `URL` methods and properties. * * @class ProxyURL * @extends {URL} */ class ProxyURL extends url_1.URL { urlString; /** * Creates an instance of the `ProxyURL` class. * * The constructor takes a base URL and an optional path. If the path is provided, it will be appended * to the base URL. If no path is provided, the URL is constructed using only the base URL. * * @param {string} baseUrl - The base URL (e.g., `http://localhost`). * @param {string} [path] - An optional path to append to the base URL (e.g., `/api`). */ constructor(baseUrl, path) { if (path) { super(path, baseUrl); // If path is provided, construct the URL with it } else { super(baseUrl); // Otherwise, use just the base URL } this.urlString = baseUrl; // Store the base URL string } } exports.ProxyURL = ProxyURL;