All files / src cli.ts

0% Statements 0/28
100% Branches 1/1
100% Functions 1/1
0% Lines 0/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
#!/usr/bin/env node
 
import { Command } from 'commander';
import chalk from 'chalk';
import { startServers } from './server.js';
 
const program = new Command();
 
console.log('Starting Arbiter...');
 
program
  .name('arbiter')
  .description('API proxy with OpenAPI generation and HAR export capabilities')
  .version('1.0.0')
  .requiredOption('-t, --target <url>', 'target API URL to proxy to')
  .option('-p, --port <number>', 'port to run the proxy server on', '8080')
  .option('-d, --docs-port <number>', 'port to run the documentation server on', '9000')
  .option('-k, --key <string>', 'API key to add to proxied requests')
  .option('--docs-only', 'run only the documentation server')
  .option('--proxy-only', 'run only the proxy server')
  .option('-v, --verbose', 'enable verbose logging')
  .parse(process.argv);
 
const options = program.opts();
 
// Start the servers
startServers({
  target: options.target,
  proxyPort: parseInt(options.port),
  docsPort: parseInt(options.docsPort),
  apiKey: options.key,
  verbose: options.verbose
}).catch((error) => {
  console.error(chalk.red('Failed to start servers:'), error);
  process.exit(1);
});