diff --git a/backend/.env.network b/backend/.env.network new file mode 100644 index 0000000..1088942 --- /dev/null +++ b/backend/.env.network @@ -0,0 +1,24 @@ +# Application +APP_ENV=development +DEBUG=true +SECRET_KEY=5yIKYt_x20Kk-9PrQVfRzDGc-RFT06vTgIGAz13I8pU + +# Database +DATABASE_URL=postgresql+asyncpg://paperdynasty:Snugly9-Gem-Configure@10.10.0.42:5432/paperdynasty_dev + +# Discord OAuth +DISCORD_CLIENT_ID=1441192438055178420 +DISCORD_CLIENT_SECRET=oj1OzUo4Qksph6mq57zb-qDiMxtb1n48 +DISCORD_REDIRECT_URI=http://10.0.0.206:3000/auth/callback +DISCORD_SERVER_REDIRECT_URI=http://10.0.0.206:8000/api/auth/discord/callback/server +FRONTEND_URL=http://10.0.0.206:3000 + +# League APIs +SBA_API_URL=https://api.sba.manticorum.com +SBA_API_KEY=Tp3aO3jhYve5NJF1IqOmJTmk +PD_API_URL=https://pd-api.example.com +PD_API_KEY=placeholder-pd-api-key + +# CORS +CORS_ORIGINS=["http://localhost:3000","http://localhost:3001","http://10.0.0.206:3000"] +ALLOWED_DISCORD_IDS=258104532423147520,139926308644847616 diff --git a/dev-native.sh b/dev-native.sh index f979048..a110658 100755 --- a/dev-native.sh +++ b/dev-native.sh @@ -61,21 +61,48 @@ check_dependencies() { # Setup environment files setup_env() { - print_status "Setting up development environment files..." + local mode=${1:-local} - # Backend - if [[ ! -f "backend/.env" ]] || ! grep -q "localhost:8000" "backend/.env" 2>/dev/null; then - print_status "Copying backend/.env.dev -> backend/.env" - cp backend/.env.dev backend/.env + if [[ "$mode" == "network" ]]; then + print_status "Setting up NETWORK environment files..." + + # Detect network IP + local network_ip=$(ip addr show | grep "inet " | grep -v "127.0.0.1" | grep -v "tailscale" | head -1 | awk '{print $2}' | cut -d'/' -f1) + + if [[ -z "$network_ip" ]]; then + print_error "Could not detect network IP" + return 1 + fi + + print_status "Detected network IP: $network_ip" + + # Backend + cp backend/.env.network backend/.env + sed -i "s|10\\.0\\.0\\.[0-9]*|$network_ip|g" backend/.env + + # Frontend + cp frontend-sba/.env.network frontend-sba/.env + sed -i "s|10\\.0\\.0\\.[0-9]*|$network_ip|g" frontend-sba/.env + + print_success "Network mode configured for $network_ip" + print_warning "Add to Discord OAuth: http://$network_ip:8000/api/auth/discord/callback/server" + else + print_status "Setting up development environment files..." + + # Backend + if [[ ! -f "backend/.env" ]] || ! grep -q "localhost:8000" "backend/.env" 2>/dev/null; then + print_status "Copying backend/.env.dev -> backend/.env" + cp backend/.env.dev backend/.env + fi + + # Frontend + if [[ ! -f "frontend-sba/.env" ]] || ! grep -q "localhost:8000" "frontend-sba/.env" 2>/dev/null; then + print_status "Copying frontend-sba/.env.dev -> frontend-sba/.env" + cp frontend-sba/.env.dev frontend-sba/.env + fi + + print_success "Environment files ready" fi - - # Frontend - if [[ ! -f "frontend-sba/.env" ]] || ! grep -q "localhost:8000" "frontend-sba/.env" 2>/dev/null; then - print_status "Copying frontend-sba/.env.dev -> frontend-sba/.env" - cp frontend-sba/.env.dev frontend-sba/.env - fi - - print_success "Environment files ready" } # Start Redis (Docker) @@ -247,11 +274,13 @@ show_logs() { # Start all services start_all() { + local mode=${1:-local} + print_status "Starting native development environment..." echo "" check_dependencies - setup_env + setup_env "$mode" start_redis || exit 1 start_backend || exit 1 @@ -260,14 +289,29 @@ start_all() { echo "" print_success "Development environment ready!" echo "" - echo -e "${GREEN}========================================${NC}" - echo -e "${GREEN} Native Development Mode${NC}" - echo -e "${GREEN}========================================${NC}" - echo "" - echo " Backend API: http://localhost:8000" - echo " API Docs: http://localhost:8000/docs" - echo " Frontend: http://localhost:3000" - echo "" + + if [[ "$mode" == "network" ]]; then + local network_ip=$(ip addr show | grep "inet " | grep -v "127.0.0.1" | grep -v "tailscale" | head -1 | awk '{print $2}' | cut -d'/' -f1) + echo -e "${GREEN}========================================${NC}" + echo -e "${GREEN} Native Development Mode (NETWORK)${NC}" + echo -e "${GREEN}========================================${NC}" + echo "" + echo " Access from ANY device on your network:" + echo " Frontend: http://$network_ip:3000" + echo " Backend: http://$network_ip:8000" + echo " API Docs: http://$network_ip:8000/docs" + echo "" + else + echo -e "${GREEN}========================================${NC}" + echo -e "${GREEN} Native Development Mode${NC}" + echo -e "${GREEN}========================================${NC}" + echo "" + echo " Backend API: http://localhost:8000" + echo " API Docs: http://localhost:8000/docs" + echo " Frontend: http://localhost:3000" + echo "" + fi + echo " Features:" echo " ✓ Hot-reload enabled (backend + frontend)" echo " ✓ No Docker rebuilds" @@ -287,22 +331,31 @@ start_all() { # Restart all services restart_all() { + local mode=${1:-local} stop_services sleep 2 - start_all + start_all "$mode" } # Show usage show_usage() { + local network_ip=$(ip addr show | grep "inet " | grep -v "127.0.0.1" | grep -v "tailscale" | head -1 | awk '{print $2}' | cut -d'/' -f1) + echo "Paper Dynasty - Native Development Mode" echo "" - echo "Usage: ./dev-native.sh " + echo "Usage: ./dev-native.sh [--network]" echo "" echo "Commands:" - echo " start Start all services natively (instant, hot-reload)" - echo " stop Stop all services" - echo " logs Tail logs from all services" - echo " restart Restart all services" + echo " start Start services (localhost only)" + echo " start --network Start services (accessible from network)" + echo " stop Stop all services" + echo " logs Tail logs from all services" + echo " restart Restart services" + echo " restart --network Restart in network mode" + echo "" + echo "Network Mode:" + echo " Your IP: $network_ip" + echo " Access: http://$network_ip:3000" echo "" echo "Benefits:" echo " • No Docker rebuilds (saves minutes)" @@ -318,9 +371,14 @@ show_usage() { } # Main +MODE="local" +if [[ "${2:-}" == "--network" ]]; then + MODE="network" +fi + case "${1:-}" in start) - start_all + start_all "$MODE" ;; stop) stop_services @@ -329,7 +387,7 @@ case "${1:-}" in show_logs ;; restart) - restart_all + restart_all "$MODE" ;; *) show_usage