Skip to content

Yemresalcan/Caching-Proxy-Server-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Caching Proxy CLI

Version Node License PRs Welcome

A modern, beautiful caching proxy server with an intuitive CLI interface

Forward requests β€’ Cache responses β€’ Boost performance

Caching Proxy CLI Screenshot

πŸ‡ΉπŸ‡· Turkish interface showing interactive menu and real-time caching statistics

✨ Features

  • 🎨 Beautiful CLI with colors, animations, and interactive mode
  • 🌍 Multi-language Support - English & Turkish (auto-detected)
  • ⚑ High Performance caching with intelligent cache key generation
  • πŸ“Š Real-time Statistics and performance metrics
  • πŸ”„ All HTTP Methods supported (GET, POST, PUT, DELETE, PATCH)
  • 🏷️ Cache Headers (X-Cache: HIT/MISS) for debugging
  • 🧹 Cache Management with clear functionality
  • πŸ“ˆ Built-in Analytics endpoint for monitoring
  • πŸ›‘οΈ Error Handling with graceful degradation
  • 🎯 Zero Configuration - works out of the box
  • πŸ”Œ Smart Port Detection - automatically finds available ports

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/Yemresalcan/caching-proxy-cli.git
cd caching-proxy-cli

# Install dependencies
npm install

# Make it globally available (optional)
npm link

Usage

Interactive Mode (Recommended)

caching-proxy --interactive
# or simply
caching-proxy

Command Line Mode

# Basic usage
caching-proxy --origin https://jsonplaceholder.typicode.com --port 3000

# Short flags
caching-proxy -o https://api.github.com -p 8080

Clear Cache

caching-proxy --clear-cache

πŸ“– Examples

Example 1: JSON API Caching

# Start proxy for JSONPlaceholder API
caching-proxy -o https://jsonplaceholder.typicode.com -p 3000

# Test it out
curl http://localhost:3000/posts/1
# First request: X-Cache: MISS (slower)

curl http://localhost:3000/posts/1
# Second request: X-Cache: HIT (much faster!)

Example 2: E-commerce API

# Cache product data from DummyJSON
caching-proxy -o https://dummyjson.com -p 3000

# Get products (cached after first request)
curl http://localhost:3000/products
curl http://localhost:3000/products/1

Example 3: Development Workflow

# Use interactive mode for development
caching-proxy --interactive

# Monitor performance
curl http://localhost:3000/__proxy_stats

πŸ“Š Monitoring & Analytics

Access real-time statistics at: http://localhost:PORT/__proxy_stats

Available Metrics:

  • Total requests processed
  • Cache hit/miss ratio
  • Average response time
  • Data served (bandwidth)
  • Cache size and uptime

🎨 CLI Features

Beautiful Interface

  • 🎭 ASCII art banner
  • 🌈 Colorized output and logs
  • ⏱️ Real-time performance metrics
  • πŸ“¦ Boxed information display

Interactive Mode

  • πŸ€” Guided setup process
  • βœ… Input validation
  • πŸ”§ Smart defaults
  • πŸ’‘ Helpful prompts

Multi-language Support

  • 🌍 Auto-detection: Automatically detects system language
  • πŸ‡ΊπŸ‡Έ English: Full English interface
  • πŸ‡ΉπŸ‡· Turkish: Complete Turkish translation
  • πŸ”„ Runtime switching: Change language during interactive mode

Smart Logging

15:30:45 GET    /api/users
  βœ“ HIT 45ms 2.1 kB

15:30:50 POST   /api/users
  βœ— MISS 234ms 1.5 kB cached

πŸ”§ Configuration

Command Line Options

Option Short Description Default
--origin -o Origin server URL Required
--port -p Proxy server port 3000
--interactive -i Interactive mode false
--clear-cache Clear cache and exit false

Environment Variables

# Set default origin (optional)
export CACHING_PROXY_ORIGIN=https://api.example.com

# Set default port (optional)
export CACHING_PROXY_PORT=3000

πŸ—οΈ How It Works

  1. Request Interception: Proxy receives HTTP request
  2. Cache Lookup: Generates unique cache key and checks cache
  3. Cache Hit: Returns cached response with X-Cache: HIT
  4. Cache Miss: Forwards to origin, caches response, returns with X-Cache: MISS
  5. Performance Tracking: Records metrics for monitoring

Cache Key Generation

// Cache key includes:
// - HTTP method (GET, POST, etc.)
// - Full URL path and query parameters
// - Request body (for POST/PUT requests)
// - Generates MD5 hash for efficient storage

πŸ› οΈ Development

Scripts

npm run dev      # Development mode with auto-reload
npm run test     # Run tests
npm run lint     # Code linting
npm run format   # Code formatting

Project Structure

caching-proxy-cli/
β”œβ”€β”€ bin/
β”‚   └── caching-proxy.js    # CLI entry point
β”œβ”€β”€ src/
β”‚   └── proxy.js           # Core proxy logic
β”œβ”€β”€ package.json
└── README.md

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


Made with ❀️ for developers who love performance

Report Bug β€’ Request Feature

About

A modern, beautiful caching proxy server with an intuitive CLI interface

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published