update
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import { SmartProxy } from '../dist_ts/index.js';
|
||||
import type { IRouteConfig } from '../dist_ts/index.js';
|
||||
|
||||
async function main() {
|
||||
// Create a SmartProxy instance with initial routes
|
||||
@ -48,13 +49,13 @@ async function main() {
|
||||
const currentRoutes = proxy.settings.routes;
|
||||
|
||||
// Create a new route for port 8081
|
||||
const newRoute = {
|
||||
const newRoute: IRouteConfig = {
|
||||
match: {
|
||||
ports: 8081,
|
||||
domains: ['api.example.com']
|
||||
},
|
||||
action: {
|
||||
type: 'forward',
|
||||
type: 'forward' as const,
|
||||
target: { host: 'localhost', port: 4000 }
|
||||
},
|
||||
name: 'API Route'
|
||||
@ -69,13 +70,13 @@ async function main() {
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
|
||||
// Add a completely new port via updateRoutes, which will automatically start listening
|
||||
const thirdRoute = {
|
||||
const thirdRoute: IRouteConfig = {
|
||||
match: {
|
||||
ports: 8082,
|
||||
domains: ['admin.example.com']
|
||||
},
|
||||
action: {
|
||||
type: 'forward',
|
||||
type: 'forward' as const,
|
||||
target: { host: 'localhost', port: 5000 }
|
||||
},
|
||||
name: 'Admin Route'
|
||||
|
Reference in New Issue
Block a user