#!/bin/bash # Makefile-like commands for Secure Proxy # Usage: source commands.sh, then use the functions # Colors GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # Functions setup() { echo -e "${BLUE}๐Ÿ“ฆ Setting up Secure Proxy...${NC}" npm install npm run init-db echo -e "${GREEN}โœ“ Setup complete!${NC}" } dev() { echo -e "${BLUE}๐Ÿš€ Starting development server...${NC}" npm run dev } start() { echo -e "${BLUE}๐Ÿš€ Starting production server...${NC}" NODE_ENV=production npm start } seed() { echo -e "${BLUE}๐ŸŒฑ Seeding database with sample data...${NC}" npm run seed-db echo -e "${GREEN}โœ“ Database seeded!${NC}" } test-api() { echo -e "${BLUE}๐Ÿงช Testing API endpoints...${NC}" bash test-api.sh } logs() { echo -e "${BLUE}๐Ÿ“Š Database info:${NC}" echo "Services:" sqlite3 db/services.db "SELECT id, name, path, target_url, enabled FROM services;" | column -t -s'|' echo "" echo "Recent Audit Logs:" sqlite3 db/services.db "SELECT action, user_id, timestamp FROM audit_logs ORDER BY timestamp DESC LIMIT 5;" | column -t -s'|' } clean() { echo -e "${YELLOW}๐Ÿงน Cleaning project...${NC}" rm -rf node_modules rm -f db/services.db rm -rf sessions/* echo -e "${GREEN}โœ“ Cleaned!${NC}" } reset() { echo -e "${RED}โš ๏ธ Resetting project...${NC}" clean setup echo -e "${GREEN}โœ“ Reset complete!${NC}" } help() { cat << EOF ${BLUE}Secure Proxy - Command Reference${NC} ${GREEN}Quick Start:${NC} setup ......... Install deps & init database dev .......... Start dev server (auto-reload) start ........ Start production server ${GREEN}Database:${NC} seed ......... Seed sample data logs ......... Show database contents clean ........ Delete database & node_modules reset ........ Full clean reinstall ${GREEN}Testing:${NC} test-api .... Test all endpoints ${GREEN}Help:${NC} help ......... Show this message ${YELLOW}Usage:${NC} source commands.sh # Load functions setup # Setup project dev # Start dev server EOF } # Export functions export -f setup dev start seed test-api logs clean reset help # Show help if sourced if [ "${BASH_SOURCE[0]}" = "${0}" ]; then help else echo -e "${GREEN}โœ“ Commands loaded! Type 'help' for available commands${NC}" fi