import { DcRouter } from '../ts/index.js'; const devRouter = new DcRouter({ // Server public IP (used for VPN AllowedIPs) publicIp: '203.0.113.1', // SmartProxy routes for development/demo smartProxyConfig: { routes: [ { name: 'web-traffic', match: { ports: [18080], domains: ['example.com', '*.example.com'] }, action: { type: 'forward', targets: [{ host: 'localhost', port: 3001 }] }, }, { name: 'api-gateway', match: { ports: [18080], domains: ['api.example.com'], path: '/v1/*' }, action: { type: 'forward', targets: [{ host: 'localhost', port: 4000 }] }, }, { name: 'tls-passthrough', match: { ports: [18443], domains: ['secure.example.com'] }, action: { type: 'forward', targets: [{ host: 'localhost', port: 4443 }], tls: { mode: 'passthrough' }, }, }, { name: 'vpn-internal-app', match: { ports: [18080], domains: ['internal.example.com'] }, action: { type: 'forward', targets: [{ host: 'localhost', port: 5000 }] }, vpn: { required: true }, }, { name: 'vpn-eng-dashboard', match: { ports: [18080], domains: ['eng.example.com'] }, action: { type: 'forward', targets: [{ host: 'localhost', port: 5001 }] }, vpn: { required: true, allowedServerDefinedClientTags: ['engineering'] }, }, ] as any[], }, // VPN with pre-defined clients vpnConfig: { enabled: true, serverEndpoint: 'vpn.dev.local', clients: [ { clientId: 'dev-laptop', serverDefinedClientTags: ['engineering', 'dev'], description: 'Developer laptop' }, { clientId: 'ci-runner', serverDefinedClientTags: ['engineering', 'ci'], description: 'CI/CD pipeline' }, { clientId: 'admin-desktop', serverDefinedClientTags: ['admin'], description: 'Admin workstation' }, ], }, // Disable cache/mongo for dev cacheConfig: { enabled: false }, }); console.log('Starting DcRouter in development mode...'); await devRouter.start(); // Graceful shutdown handlers const shutdown = async () => { console.log('\nShutting down...'); await devRouter.stop(); process.exit(0); }; process.on('SIGINT', shutdown); process.on('SIGTERM', shutdown); console.log('DcRouter dev server running. Press Ctrl+C to stop.');