Package Exports
- @javagt/reverse-proxy-client
- @javagt/reverse-proxy-client/src/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@javagt/reverse-proxy-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@javagt/reverse-proxy-client
A Node.js SDK for interacting with the javagrant.ac.nz Reverse Proxy Registry Server.
Installation
npm install @javagt/reverse-proxy-clientUsage
import { ReverseProxyClient } from "@javagt/reverse-proxy-client";
const client = new ReverseProxyClient({
apiBase: "http://127.0.0.1:24789/api", // Base URL of your Registry Server API
apiKey: "YOUR_API_KEY" // An API key generated in the Registry Dashboard
});
async function main() {
// 1. List all active routes
const routes = await client.listRoutes();
console.log("Current routes:", routes);
// 2. Add a new route dynamically
await client.addRoute({
subdomain: "new-service",
baseDomain: "example.com",
destAddress: "127.0.0.1",
destPort: 8080,
rateLimit: 120 // Optional: requests per minute
});
console.log("Added new-service.example.com");
// 3. Remove a route
await client.removeRoute("new-service", "example.com");
console.log("Removed new-service.example.com");
}
main().catch(console.error);API Reference
new ReverseProxyClient(options)
options.apiBase(string): Base URL of the Registry Server API (e.g.,http://127.0.0.1:24789/api).options.apiKey(string): API key for authentication.
client.listRoutes()
Returns a promise that resolves to an array of currently registered routes.
client.addRoute(options)
Registers a new route. Returns a promise.
options.subdomain(string, required): Subdomain to route (e.g.,api).options.baseDomain(string, required): Base domain to route (e.g.,example.com).options.destAddress(string, required): Internal destination IP/hostname.options.destPort(number, required): Internal destination port.options.rateLimit(number, optional, default: 100): Requests per minute limit.
client.removeRoute(subdomain, baseDomain)
Removes an existing route. Returns a promise.
subdomain(string, required)baseDomain(string, required)