mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-10-25 12:37:52 +09:00
Introduce fallback audit logging and enrich audit tooling; add builtin extension discovery/install; and update default launcher ports and related docs/config. Key changes: - New middleware app.middleware.audit registers an after-request fallback that records authenticated mutating API requests when routes don't emit explicit audit logs. - Audit model/action constants extended and AuditService enhanced (request context handling, redaction for sensitive settings, optional commit flag, sets g.audit_logged, emits events). - Routes/services updated to create explicit audit entries for marketplace and plugin operations (create/update/publish/install/uninstall/enable/disable) and SSO/settings flows switched to use AuditService. - Added tests for audit logging behavior and redaction (backend/tests/test_audit_log.py). - Plugin service: added BUILTIN_EXTENSIONS_DIR, list_builtin_extensions and install_builtin_extension; plugin API endpoints to list/install builtin extensions. - Contribution system extended to support layouts and route layout metadata; frontend wiring updated to surface standalone/custom layouts and extension routes. - Launcher port defaults changed (backend -> 47927, frontend -> 41921). Updated backend .env.example, config CORS defaults, Dockerfiles and docker-compose to use SERVERKIT_BACKEND_PORT, and many docs/README files and frontend envs to reflect new ports. - Minor frontend cleanups and new builtin extension example (serverkit-git) plus associated manifest and frontend re-export. These changes improve observability/security for mutating APIs, enable opt-in builtin plugins, and align local dev/run ports with the launcher defaults.
92 lines
2.9 KiB
Bash
Executable File
92 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# ServerKit Local Development Setup for WSL/Linux
|
|
# Usage: ./dev-setup.sh
|
|
#
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${BLUE}"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo " ServerKit Development Setup"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo -e "${NC}"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
# Check if Python is installed
|
|
if ! command -v python3 &> /dev/null; then
|
|
echo -e "${YELLOW}Installing Python...${NC}"
|
|
sudo apt update
|
|
sudo apt install -y python3 python3-pip python3-venv python3-dev
|
|
fi
|
|
|
|
# Check if Node is installed
|
|
if ! command -v node &> /dev/null; then
|
|
echo -e "${YELLOW}Installing Node.js...${NC}"
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
sudo apt install -y nodejs
|
|
fi
|
|
|
|
# Create virtual environment
|
|
if [ ! -d "venv" ]; then
|
|
echo -e "${BLUE}→ Creating Python virtual environment...${NC}"
|
|
python3 -m venv venv
|
|
fi
|
|
|
|
# Activate and install dependencies
|
|
echo -e "${BLUE}→ Installing Python dependencies...${NC}"
|
|
source venv/bin/activate
|
|
pip install --quiet --upgrade pip
|
|
pip install --quiet -r backend/requirements.txt
|
|
pip install --quiet gunicorn gevent gevent-websocket
|
|
|
|
# Install frontend dependencies
|
|
echo -e "${BLUE}→ Installing frontend dependencies...${NC}"
|
|
cd frontend
|
|
npm install --silent
|
|
cd ..
|
|
|
|
# Create .env if not exists
|
|
if [ ! -f ".env" ]; then
|
|
echo -e "${BLUE}→ Creating .env file...${NC}"
|
|
cat > .env << 'EOF'
|
|
# Development Configuration
|
|
SECRET_KEY=dev-secret-key-change-in-production
|
|
JWT_SECRET_KEY=dev-jwt-key-change-in-production
|
|
DATABASE_URL=sqlite:///backend/instance/serverkit.db
|
|
CORS_ORIGINS=http://localhost:41921,http://127.0.0.1:41921,http://localhost:47927,http://127.0.0.1:47927
|
|
FLASK_ENV=development
|
|
PORT=47927
|
|
EOF
|
|
fi
|
|
|
|
# Create instance directory
|
|
mkdir -p backend/instance
|
|
|
|
echo ""
|
|
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo -e "${GREEN} Setup Complete!${NC}"
|
|
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo ""
|
|
echo "To start development:"
|
|
echo ""
|
|
echo " Terminal 1 (Backend):"
|
|
echo " source venv/bin/activate"
|
|
echo " cd backend && python run.py"
|
|
echo ""
|
|
echo " Terminal 2 (Frontend):"
|
|
echo " cd frontend && npm run dev"
|
|
echo ""
|
|
echo "Access:"
|
|
echo " Frontend: http://localhost:41921"
|
|
echo " Backend: http://localhost:47927"
|
|
echo ""
|