Global CLI tool for managing Redirector backend services with Docker Compose
npm install redirector-cli

A global CLI tool for managing Redirector backend services with Docker Compose. Deploy and manage your Redirector API anywhere with zero configuration.
``bashInstall globally
npm install -g redirector-cli
Your Redirector API will be available at
http://localhost:3000!๐ Requirements
- Node.js 16.0.0 or higher
- Docker and Docker Compose
- npm or yarn
๐ Installation
$3
`bash
npm install -g redirector-cli
`$3
`bash
npx redirector-cli setup
`๐ Commands
$3
Initialize a new Redirector project in the current directory.
`bash
redirector setup [options]Options:
-p, --port Backend API port (default: 3000)
--postgres-port PostgreSQL port (default: 5432)
-u, --docker-username Docker Hub username (default: shivarajbakale)
-f, --force Overwrite existing configuration
--no-interactive Skip interactive prompts
`Examples:
`bash
Interactive setup
redirector setupNon-interactive with custom port
redirector setup --port 8080 --no-interactiveForce overwrite existing project
redirector setup --force
`$3
Start all Redirector services.
`bash
redirector start [options]Options:
--no-detach Run in foreground (not detached)
--pull Pull latest images before starting
--build Build images before starting
`Examples:
`bash
Start services in background
redirector startStart with latest images
redirector start --pullStart in foreground
redirector start --no-detach
`$3
Stop all Redirector services.
`bash
redirector stop [options]Options:
-v, --remove-volumes Also remove volumes and data
`Examples:
`bash
Stop services
redirector stopStop and remove all data
redirector stop --remove-volumes
`$3
Restart all Redirector services.
`bash
redirector restart [options]Options:
--pull Pull latest images before restarting
`$3
Stop services and remove all data and volumes.
`bash
redirector reset [options]Options:
-f, --force Skip confirmation prompt
-y, --confirm Automatically confirm reset
`โ ๏ธ Warning: This will permanently delete all data!
$3
Show status of all services.
`bash
redirector status [options]Options:
-j, --json Output status as JSON
-v, --verbose Show detailed information
`Examples:
`bash
Human-readable status
redirector statusJSON output for scripts
redirector status --jsonDetailed information
redirector status --verbose
`$3
Show logs for services.
`bash
redirector logs [service] [options]Arguments:
service Service name (backend, postgres, or all)
Options:
-f, --follow Follow log output
-t, --tail Number of lines to show from end of logs
`Examples:
`bash
Show all logs
redirector logsShow backend logs only
redirector logs backendFollow all logs
redirector logs --followFollow backend logs
redirector logs backend --follow
`๐ง Configuration
The CLI uses the following configuration sources (in order of precedence):
1. Command-line options
2. Environment variables
3.
.redirector.json file
4. Default values$3
`bash
BACKEND_PORT=3000 # Backend API port
POSTGRES_PORT=5432 # PostgreSQL port
DOCKER_USERNAME=shivarajbakale # Docker Hub username
PROJECT_NAME=redirector # Project name
NODE_ENV=production # Environment (production/development)
`$3
The CLI creates a
.redirector.json file in your project:`json
{
"backendPort": 3000,
"postgresPort": 5432,
"dockerUsername": "shivarajbakale",
"projectName": "my-project",
"environment": "production"
}
`๐ Project Structure
After running
redirector setup, your project will contain:`
my-redirector/
โโโ docker-compose.yml # Docker Compose configuration
โโโ .env # Environment variables
โโโ .redirector.json # CLI configuration
โโโ .gitignore # Git ignore rules
โโโ README.md # Project documentation
โโโ data/ # Volume mount directory
`๐ API Endpoints
Once started, your Redirector API provides:
- Health Check:
GET /health
- Groups: GET /groups/list, POST /groups/create
- Requests: GET /requests, POST /requests/createFull API documentation: Redirector API Docs
๐ณ Docker Images
The CLI uses pre-built Docker images:
- Backend:
shivarajbakale/redirector-backend:latest
- Database: postgres:15Images are automatically pulled when starting services.
๐ Troubleshooting
$3
`bash
Check Docker installation
docker --version
docker compose versionCheck Docker daemon
docker infoCheck running containers
docker ps
`$3
`bash
Check if port is in use
lsof -i :3000Use custom port
redirector setup --port 8080
`$3
`bash
Check service status
redirector statusView service logs
redirector logsTest API health
curl http://localhost:3000/health
`$3
`bash
Complete reset
redirector reset --forceRestart setup
redirector setup --force
`๐งช Development
$3
`bash
Clone repository
git clone https://github.com/shivarajbakale/redirector-app.git
cd redirector-app/packages/backend/cliInstall dependencies
npm installBuild
npm run buildTest locally
npm link
redirector --help
`$3
`bash
Run all tests
npm testRun tests with coverage
npm run test:coverageRun tests in watch mode
npm run test:watch
`$3
`bash
Check code style
npm run lintFix code style
npm run lint:fix
`๐ Examples
$3
`bash
Create new project
mkdir my-api && cd my-api
redirector setupStart services
redirector startTest API
curl http://localhost:3000/healthStop services
redirector stop
`$3
`bash
Setup with custom ports
redirector setup --port 8080 --postgres-port 5433Start with latest images
redirector start --pullMonitor logs
redirector logs --follow
`$3
`bash
Setup production environment
redirector setup --no-interactive
export NODE_ENV=productionStart services
redirector startMonitor status
redirector status --json
`$3
`bash
#!/bin/bash
deploy.sh
Install CLI
npm install -g redirector-cliSetup project
redirector setup --no-interactive --forceStart services
redirector start --pullWait for health check
until curl -f http://localhost:3000/health; do
echo "Waiting for API..."
sleep 5
doneecho "Deployment successful!"
`๐ค Contributing
1. Fork the repository
2. Create your feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)This project is licensed under the MIT License - see the LICENSE file for details.
- Main Repository: redirector-app
- Docker Hub: shivarajbakale/redirector-backend
- npm Package: redirector-cli
- Issues: GitHub Issues
If you find this project helpful, please consider:
- โญ Starring the repository
- ๐ Reporting bugs
- ๐ก Suggesting features
- ๐ Improving documentation
---
Made with โค๏ธ by Shivaraj Bakale