57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { DcRouter } from '../ts/index.js';
|
|
|
|
const devRouter = new DcRouter({
|
|
// 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' },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
// 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.');
|