A comprehensive VPS and domain management API built with Elysia.js and Bun runtime. This API enables users to manage their Virtual Private Servers (VPS), domains, and GitHub authentication configurations.
- Overview
- Features
- Tech Stack
- Architecture
- Getting Started
- API Endpoints
- Database Schema
- Security
- Environment Variables
The Deployment Manager API provides a secure interface for managing VPS machines, domains, and GitHub authentication. It uses JWT-based authentication, encrypted password storage, and SSH connectivity for remote server management.
- VPS Management: Add, update, delete, and retrieve VPS machines
- Domain Management: Add, delete, and retrieve user domains
- GitHub Authentication: Configure GitHub credentials on VPS machines
- Machine Analytics: View real-time system information (CPU, RAM, disk, OS)
- Secure Authentication: JWT token-based access control
- Password Encryption: AES encryption for VPS passwords
- SSH Integration: Remote command execution via SSH2
- Runtime: Bun
- Framework: Elysia.js
- Database: PostgreSQL with Drizzle ORM
- Authentication: JWT (jsonwebtoken)
- Encryption: CryptoJS
- SSH: ssh2 library
- CORS: @elysiajs/cors
┌─────────────┐
│ Client │
└──────┬──────┘
│ HTTP Request
▼
┌─────────────────┐
│ Elysia App │
│ (index.ts) │
└──────┬──────────┘
│
├──► CORS Middleware
│
├──► Auth Middleware (checkAuth)
│ └──► JWT Verification
│
└──► Route Handlers
│
├──► Controllers
│ ├──► Machines
│ ├──► Domains
│ └──► GitHub
│
├──► Database (Drizzle ORM)
│ └──► PostgreSQL
│
├──► SSH Client
│ └──► Remote VPS Commands
│
└──► Crypto Utils
└──► Password Encryption/Decryption
- Bun runtime installed
- PostgreSQL database
- Node.js (for npm packages)
# Install dependencies
bun install
# Set up environment variables (see Environment Variables section)
cp .env.example .env
# Generate database migrations
bun run generate
# Run migrations
bun run migrate
# Start development server
bun run devbun run build| Method | Path | Description |
|---|---|---|
| GET | / |
API welcome message |
| Method | Path | Description |
|---|---|---|
| POST | /add-machine |
Add a new VPS machine |
| GET | /get-machines |
Get all user's VPS machines |
| PUT | /update-machine/:id |
Update VPS password or expiry date |
| DELETE | /delete-machine/:id |
Delete a VPS machine |
| GET | /get-machine-analytics/:id |
Get real-time machine analytics |
| Method | Path | Description |
|---|---|---|
| POST | /add-domain |
Add a new domain |
| GET | /get-domains |
Get all user's domains |
| DELETE | /delete-domain/:id |
Delete a domain |
| Method | Path | Description |
|---|---|---|
| POST | /authenticate-github/:id |
Authenticate GitHub on a VPS |
| GET | /unauthenticate-github/:id |
Remove GitHub authentication |
| GET | /get-github-auths/:id |
Get GitHub authentication status |
-
vps_machines: Stores VPS machine information
- id, vps_ip, vps_name, vps_password (encrypted)
- ownerId, ssh_key (encrypted), ram, storage, cpu_cores
- expiryDate, added_at, updated_at
-
user_domains: Stores user domain configurations
- id, domain_address, vps_ip, ownerId
- isDeployed, added_at
-
github_auths: Stores GitHub authentication records
- id, vpsId, github_username, added_at
- JWT Authentication: All protected routes require valid access token
- Password Encryption: VPS passwords encrypted using AES encryption
- Owner Verification: Users can only access their own resources
- SQL Injection Prevention: Drizzle ORM with parameterized queries
- CORS Protection: Configured for specific origins
- Input Validation: Required field validation on all endpoints
# Server Configuration
PORT=3000
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
# JWT
ACCESS_TOKEN_SECRET=your-secret-key-here
# Encryption
ENCRYPTION_KEY=your-encryption-key-here
ENCRYPTION_ALGORITHM=AES{
"status": "success",
"data": { ... },
"message": "Optional message"
}{
"status": "error",
"message": "Error description",
"error": "Detailed error message (optional)"
}200- OK201- Created400- Bad Request401- Unauthorized403- Forbidden404- Not Found419- Expired Token500- Internal Server Error
# Watch mode
bun run dev
# Generate migrations
bun run generate
# Run migrations
bun run migrateCopyright © Zyotra
For detailed technical documentation, see DOCUMENTATION.md