Welcome to the Sabay CLI tool and API server documentation. This repository consists of two main components:
-
Sabay CLI - A Node.js-based command-line interface for managing stacks and services.
-
Sabay API Server - A Flask-based server handling authentication and stack operations.
The Sabay CLI is a command-line interface designed to manage various Sabay services and stacks. With it, you can:
- Fetch an authentication token.
- Update a stack for a specified service.
- List all available stacks.
- List services for a given stack by stack name or stack ID.
The API Server is a Flask-based REST API that:
- Handles token management.
- Provides endpoints for listing and updating stacks.
- Authenticates users via an external login system.
- Node.js (v14.x or above)
- Python (v3.8 or above)
- pip (Python package manager)
- Flask and required Python modules (for API server)
- dotenv for environment variables
- Selenium and ChromeDriver (for token fetching)
git clone https://github.com/koompi/sabay-cli
cd sabay-cli
cd cli
make
cd server
make
source venv/bin/activate
python main.py
DB_URI="mongodb://localhost:27017/
USERNAME=koompi
PASSWORD=koompidummypassword
The Sabay CLI can be accessed using the sabay
command after installation. Below are the available commands and their descriptions:
Usage:
sabay --token
Fetch a new authentication token.
sabay --updatestack <serviceName>
Update the stack for the specified service.
sabay --liststack
List all available stacks.
sabay --listservice <stackIdentifier>
List services for a stack identified by name or ID.
sabay --logstack <stackIdentifier>
Fetch and display logs for all services in the specified stack.
The Flask API server provides the following endpoints:
-
/api/getAuth
(GET): Fetches an authentication token, checking if it’s older than 1 hour and retrieves a new one if necessary. Example:curl http://localhost:8084/api/getAuth
-
/api/updateStack
(POST): Updates a stack using the provided token. Example:curl -X POST -H "Authorization: Bearer <TOKEN>" -d '{"stackId": "123"}' http://localhost:8084/api/updateStack
-
/api/listStack
(GET): Lists all available stacks. Example:curl http://localhost:8084/api/listStack
-
/api/listservices
(POST): Retrieves the services for a stack bystackId
. Example:curl -X POST -H "Content-Type: application/json" -d '{"serviceId": "123", "subscriptionId": "123"}' http://localhost:8084/api/listservices
-
/api/logService
(POST): Retrieves the service log byServiceId
. Example:curl -X POST -H "Content-Type: application/json" -d '{"serviceId": "123", "subscriptionId": "123"}' http://localhost:8084/api/logService
The project is divided into two main directories:
sabay-cli/
│
├── cli/ # CLI tool written in Node.js
│ ├── commands/ # Contains individual command implementations
│ ├── index.js # Main CLI entry point
│ └── package.json # CLI dependencies
│
└── server/ # Flask API Server
├── main.py # Main Flask application
├── utils/ # Contains utility functions
└── requirements.txt # Python dependencies
-
Selenium Token Fetching Issues: If token fetching fails:
- Ensure your credentials are correct.
- Make sure you’re not blocked due to multiple failed login attempts.
- Check the login URL for any updates.
-
Token Not Found in Local Storage:
- The token might not be stored or available due to incorrect login or session issues. You may need to manually check if the site has changed its storage methods.