105 lines
2.4 KiB
Bash
105 lines
2.4 KiB
Bash
#!/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
|