diff --git a/README.md b/README.md index 6a577be..63dd223 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Changemaker Lite -Changemaker Lite is a streamlined documentation and development platform featuring essential self-hosted services for creating, managing, and automating content workflows. +Changemaker Lite is a streamlined documentation and development platform featuring essential self-hosted services for creating, managing, and automating political campaign workflows. ## Features diff --git a/config.sh b/config.sh index b9193a1..9bbba49 100755 --- a/config.sh +++ b/config.sh @@ -20,7 +20,7 @@ EOF # Get the absolute path of the script directory SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ENV_FILE="$SCRIPT_DIR/.env" -MKDOCS_YML="$SCRIPT_DIR/mkdocs/docs/mkdocs.yml" +MKDOCS_YML="$SCRIPT_DIR/mkdocs/mkdocs.yml" # Fixed path - removed extra 'docs' directory TUNNEL_CONFIG_DIR="$SCRIPT_DIR/configs/cloudflare" TUNNEL_CONFIG_FILE="$TUNNEL_CONFIG_DIR/tunnel-config.yml" SERVICES_YAML="$SCRIPT_DIR/configs/homepage/services.yaml" @@ -322,11 +322,11 @@ update_mkdocs_yml() { cp "$MKDOCS_YML" "$backup_file" echo "Created backup of mkdocs.yml at $backup_file" - # Update the site_url value + # Update the site_url value - handle both http and https sed -i "s|^site_url:.*|site_url: https://$new_domain|" "$MKDOCS_YML" if grep -q "site_url: https://$new_domain" "$MKDOCS_YML"; then - echo "Updated site_url in mkdocs.yml to: https://$new_domain" + echo "✅ Updated site_url in mkdocs.yml to: https://$new_domain" return 0 else echo "Warning: Failed to update site_url in mkdocs.yml" @@ -351,18 +351,25 @@ update_services_yaml() { cp "$SERVICES_YAML" "$backup_file" echo "Created backup of services.yaml at $backup_file" - # Update the commented URLs to use the new domain - sed -i "s|# href: \"https://code\.changeme\.org\"|# href: \"https://code.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|# href: \"https://listmonk\.changeme\.org\"|# href: \"https://listmonk.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|# href: \"https://db\.changeme\.org\"|# href: \"https://db.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|# href: \"https://docs\.changeme\.org\"|# href: \"https://docs.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|# href: \"https://n8n\.changeme\.org\"|# href: \"https://n8n.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|# href: \"https://test\.com\"|# href: \"https://$new_domain\"|g" "$SERVICES_YAML" + # Update all domain references - handle the current domain (albertademocracytaskforce.org) + # First, update any existing domain to the new domain + sed -i "s|albertademocracytaskforce\.org|$new_domain|g" "$SERVICES_YAML" - # Also update any remaining changeme.org references + # Also update any changeme.org references that might exist sed -i "s|changeme\.org|$new_domain|g" "$SERVICES_YAML" - echo "Updated service URLs in services.yaml to use domain: $new_domain" + # Update specific service URLs with proper formatting + sed -i "s|# href: \"https://code\.[^\"]*\"|# href: \"https://code.$new_domain\"|g" "$SERVICES_YAML" + sed -i "s|# href: \"https://listmonk\.[^\"]*\"|# href: \"https://listmonk.$new_domain\"|g" "$SERVICES_YAML" + sed -i "s|# href: \"https://db\.[^\"]*\"|# href: \"https://db.$new_domain\"|g" "$SERVICES_YAML" + sed -i "s|# href: \"https://git\.[^\"]*\"|# href: \"https://git.$new_domain\"|g" "$SERVICES_YAML" + sed -i "s|# href: \"https://docs\.[^\"]*\"|# href: \"https://docs.$new_domain\"|g" "$SERVICES_YAML" + sed -i "s|# href: \"https://n8n\.[^\"]*\"|# href: \"https://n8n.$new_domain\"|g" "$SERVICES_YAML" + + # Update root domain reference + sed -i "s|# href: \"https://[^/\"]*\"|# href: \"https://$new_domain\"|g" "$SERVICES_YAML" | tail -1 + + echo "✅ Updated service URLs in services.yaml to use domain: $new_domain" return 0 } @@ -383,227 +390,99 @@ update_main_html() { cp "$MAIN_HTML" "$backup_file" echo "Created backup of main.html at $backup_file" - # Update the login button href to use the new domain - sed -i "s|href=\"https://homepage\.test\.com\"|href=\"https://homepage.$new_domain\"|g" "$MAIN_HTML" + # Update the login button href - handle current domain + sed -i "s|href=\"https://homepage\.[^\"]*\"|href=\"https://homepage.$new_domain\"|g" "$MAIN_HTML" - # Also update any other test.com references - sed -i "s|homepage\.test\.com|homepage.$new_domain|g" "$MAIN_HTML" + # Also update any albertademocracytaskforce.org references + sed -i "s|albertademocracytaskforce\.org|$new_domain|g" "$MAIN_HTML" - echo "Updated login URL in main.html to: https://homepage.$new_domain" + # Update any test.com or changeme.org references + sed -i "s|test\.com|$new_domain|g" "$MAIN_HTML" + sed -i "s|changeme\.org|$new_domain|g" "$MAIN_HTML" + + echo "✅ Updated login URL in main.html to: https://homepage.$new_domain" return 0 } -# Function to check if a port is in use -check_port() { - local port=$1 - if command -v ss >/dev/null 2>&1; then - ss -tuln | grep -q ":$port " - elif command -v netstat >/dev/null 2>&1; then - netstat -tuln | grep -q ":$port " - else - # Fallback to lsof if available - if command -v lsof >/dev/null 2>&1; then - lsof -i ":$port" >/dev/null 2>&1 - else - echo "Warning: Cannot check port availability. Please ensure ports are free manually." - return 1 - fi - fi -} - -# Function to check all service ports for conflicts -check_port_conflicts() { - echo "Checking for port conflicts..." +# Function to update the tunnel configuration file with new domain +update_tunnel_config() { + local new_domain=$1 - local ports_to_check=( - "${CODE_SERVER_PORT:-8888}:Code Server" - "${LISTMONK_PORT:-9000}:Listmonk" - "${LISTMONK_DB_PORT:-5432}:Listmonk Database" - "${MKDOCS_PORT:-4000}:MkDocs" - "${MKDOCS_SITE_SERVER_PORT:-4001}:MkDocs Site Server" - "${N8N_PORT:-5678}:N8N" - "${NOCODB_PORT:-8090}:NocoDB" - "${HOMEPAGE_PORT:-3010}:Homepage" - "${GITEA_WEB_PORT:-3030}:Gitea Web" - "${GITEA_SSH_PORT:-2222}:Gitea SSH" - ) - - local conflicts_found=false - - for port_info in "${ports_to_check[@]}"; do - local port=$(echo "$port_info" | cut -d: -f1) - local service=$(echo "$port_info" | cut -d: -f2) + if [ ! -f "$TUNNEL_CONFIG_FILE" ]; then + echo "Warning: tunnel-config.yml not found at $TUNNEL_CONFIG_FILE" + echo "Creating new tunnel configuration file..." - if check_port "$port"; then - echo "⚠️ Port conflict detected: $port is already in use (assigned to $service)" - conflicts_found=true - else - echo "✅ Port $port is available for $service" - fi - done - - if [ "$conflicts_found" = true ]; then - echo "" - echo "Port conflicts detected! Please choose alternative ports or stop conflicting services." - read -p "Do you want to configure alternative ports? [Y/n]: " configure_ports - - if [[ "$configure_ports" =~ ^[Nn]$ ]]; then - echo "Configuration cancelled. Please resolve port conflicts and try again." - exit 1 - else - configure_alternative_ports - fi - else - echo "✅ All ports are available!" - fi -} - -# Function to configure alternative ports -configure_alternative_ports() { - echo "" - echo "---- Port Configuration ----" - - # Code Server - if check_port "${CODE_SERVER_PORT:-8888}"; then - read -p "Enter alternative port for Code Server [current: ${CODE_SERVER_PORT:-8888}]: " new_code_port - if [ ! -z "$new_code_port" ]; then - update_env_var "CODE_SERVER_PORT" "$new_code_port" - fi + # Create the file if it doesn't exist + create_tunnel_config "$new_domain" "${CF_TUNNEL_ID:-\${CF_TUNNEL_ID}}" + return $? fi - # Listmonk - if check_port "${LISTMONK_PORT:-9000}"; then - read -p "Enter alternative port for Listmonk [current: ${LISTMONK_PORT:-9000}]: " new_listmonk_port - if [ ! -z "$new_listmonk_port" ]; then - update_env_var "LISTMONK_PORT" "$new_listmonk_port" - fi - fi + echo "Updating tunnel configuration with new domain..." - # Listmonk DB - if check_port "${LISTMONK_DB_PORT:-5432}"; then - read -p "Enter alternative port for Listmonk Database [current: ${LISTMONK_DB_PORT:-5432}]: " new_db_port - if [ ! -z "$new_db_port" ]; then - update_env_var "LISTMONK_DB_PORT" "$new_db_port" - fi - fi + # Create a backup of the tunnel-config.yml file + local timestamp=$(date +"%Y%m%d_%H%M%S") + local backup_file="${TUNNEL_CONFIG_FILE}.backup_${timestamp}" + cp "$TUNNEL_CONFIG_FILE" "$backup_file" + echo "Created backup of tunnel-config.yml at $backup_file" - # MkDocs - if check_port "${MKDOCS_PORT:-4000}"; then - read -p "Enter alternative port for MkDocs [current: ${MKDOCS_PORT:-4000}]: " new_mkdocs_port - if [ ! -z "$new_mkdocs_port" ]; then - update_env_var "MKDOCS_PORT" "$new_mkdocs_port" - fi - fi + # Since the current file has all entries as cmlite.org pointing to port 3010, + # we need to recreate it with the proper configuration + echo "Regenerating tunnel configuration with correct service mappings..." - # MkDocs Site Server - if check_port "${MKDOCS_SITE_SERVER_PORT:-4001}"; then - read -p "Enter alternative port for MkDocs Site Server [current: ${MKDOCS_SITE_SERVER_PORT:-4001}]: " new_site_port - if [ ! -z "$new_site_port" ]; then - update_env_var "MKDOCS_SITE_SERVER_PORT" "$new_site_port" - fi - fi + # Load current environment variables to get port numbers + load_env_vars - # N8N - if check_port "${N8N_PORT:-5678}"; then - read -p "Enter alternative port for N8N [current: ${N8N_PORT:-5678}]: " new_n8n_port - if [ ! -z "$new_n8n_port" ]; then - update_env_var "N8N_PORT" "$new_n8n_port" - fi - fi - - # NocoDB - if check_port "${NOCODB_PORT:-8090}"; then - read -p "Enter alternative port for NocoDB [current: ${NOCODB_PORT:-8090}]: " new_nocodb_port - if [ ! -z "$new_nocodb_port" ]; then - update_env_var "NOCODB_PORT" "$new_nocodb_port" - fi - fi - - # Homepage - if check_port "${HOMEPAGE_PORT:-3010}"; then - read -p "Enter alternative port for Homepage [current: ${HOMEPAGE_PORT:-3010}]: " new_homepage_port - if [ ! -z "$new_homepage_port" ]; then - update_env_var "HOMEPAGE_PORT" "$new_homepage_port" - fi - fi - - # Gitea Web - if check_port "${GITEA_WEB_PORT:-3030}"; then - read -p "Enter alternative port for Gitea Web [current: ${GITEA_WEB_PORT:-3030}]: " new_gitea_web_port - if [ ! -z "$new_gitea_web_port" ]; then - update_env_var "GITEA_WEB_PORT" "$new_gitea_web_port" - fi - fi - - # Gitea SSH - if check_port "${GITEA_SSH_PORT:-2222}"; then - read -p "Enter alternative port for Gitea SSH [current: ${GITEA_SSH_PORT:-2222}]: " new_gitea_ssh_port - if [ ! -z "$new_gitea_ssh_port" ]; then - update_env_var "GITEA_SSH_PORT" "$new_gitea_ssh_port" - fi - fi - - echo "Port configuration completed." -} - -# Function to create Cloudflare tunnel configuration file -create_tunnel_config() { - local domain=$1 - local tunnel_id=$2 - - # Ensure the tunnel config directory exists - if [ ! -d "$TUNNEL_CONFIG_DIR" ]; then - echo "Creating Cloudflare tunnel config directory at $TUNNEL_CONFIG_DIR" - mkdir -p "$TUNNEL_CONFIG_DIR" - fi - - echo "Creating Cloudflare tunnel configuration file..." - - # Generate the tunnel configuration file with simpler format + # Recreate the tunnel configuration with proper mappings cat > "$TUNNEL_CONFIG_FILE" << EOL # filepath: /home/bunker-admin/changemaker.lite/configs/cloudflare/tunnel-config.yml # Cloudflare Tunnel Configuration # Auto-generated by Changemaker Configuration Wizard -tunnel: $tunnel_id # e.g. 1234567890abcdef -credentials-file: /home/coder/.cloudflared/$tunnel_id.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json +tunnel: ${CF_TUNNEL_ID:-\${CF_TUNNEL_ID}} # e.g. 1234567890abcdef +credentials-file: /home/coder/.cloudflared/${CF_TUNNEL_ID:-\${CF_TUNNEL_ID}}.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json ingress: - - hostname: homepage.$domain + - hostname: homepage.$new_domain service: http://localhost:${HOMEPAGE_PORT:-3010} - - hostname: code.$domain + - hostname: code.$new_domain service: http://localhost:${CODE_SERVER_PORT:-8888} - - hostname: listmonk.$domain + - hostname: listmonk.$new_domain service: http://localhost:${LISTMONK_PORT:-9000} - - hostname: docs.$domain + - hostname: docs.$new_domain service: http://localhost:${MKDOCS_PORT:-4000} - - hostname: $domain + - hostname: $new_domain service: http://localhost:${MKDOCS_SITE_SERVER_PORT:-4001} - - hostname: n8n.$domain + - hostname: n8n.$new_domain service: http://localhost:${N8N_PORT:-5678} - - hostname: db.$domain + - hostname: db.$new_domain service: http://localhost:${NOCODB_PORT:-8090} - - hostname: git.$domain + - hostname: git.$new_domain service: http://localhost:${GITEA_WEB_PORT:-3030} # Catch-all rule (required) - service: http_status:404 EOL - - echo "✅ Tunnel configuration file created at: $TUNNEL_CONFIG_FILE" - # If the tunnel ID is a placeholder, provide instructions - if [[ "$tunnel_id" == "\${CF_TUNNEL_ID}" ]]; then - echo "NOTE: You need to replace ${CF_TUNNEL_ID} with your actual Cloudflare Tunnel ID" - echo " once you create a tunnel in the Cloudflare Zero Trust dashboard." - fi + echo "✅ Regenerated tunnel configuration with correct service mappings for domain: $new_domain" + return 0 +} + +# Function to get Cloudflare API Token and Zone ID +get_cloudflare_credentials() { + echo "" + echo "To use the DNS setup script, you'll need Cloudflare credentials." + echo "You can find these values in your Cloudflare dashboard:" + echo " - API Token: https://dash.cloudflare.com/profile/api-tokens" + echo " (Create a token with Zone:DNS:Edit and Access:Apps:Edit permissions)" + echo " - Zone ID: On your domain's overview page" + echo "" } # Function to show tunnel setup instructions @@ -704,88 +583,40 @@ echo "Domain settings updated successfully!" # Cloudflare Configuration echo -e "\n---- Cloudflare Configuration ----" -echo "To use the DNS setup script, you'll need Cloudflare credentials." -echo "You can find these values in your Cloudflare dashboard:" -echo " - API Token: https://dash.cloudflare.com/profile/api-tokens" -echo " (Create a token with Zone:DNS:Edit and Access:Apps:Edit permissions)" -echo " - Zone ID: On your domain's overview page" -echo " - Tunnel ID: In the Zero Trust dashboard under Access > Tunnels" -echo "" +get_cloudflare_credentials read -p "Do you want to configure Cloudflare settings now? [Y/n]: " configure_cf if [[ ! "$configure_cf" =~ ^[Nn]$ ]]; then - echo "" - echo "Please enter your Cloudflare credentials:" - - # CF API Token + # Get Cloudflare API Token read -p "Enter your Cloudflare API Token: " cf_api_token - if [ ! -z "$cf_api_token" ]; then - # Basic validation for API token format - if [[ "$cf_api_token" =~ ^[A-Za-z0-9_-]{40}$ ]]; then - update_env_var "CF_API_TOKEN" "$cf_api_token" - echo "✅ Cloudflare API Token updated" - else - echo "⚠️ Warning: API Token format seems incorrect (should be 40 characters)" - update_env_var "CF_API_TOKEN" "$cf_api_token" - fi - else - echo "⚠️ Cloudflare API Token left unchanged" - fi + while [ -z "$cf_api_token" ] || [ "$cf_api_token" == "your_cloudflare_api_token" ]; do + echo "API Token is required. Please enter a valid token." + read -p "Enter your Cloudflare API Token: " cf_api_token + done - # CF Zone ID + # Get Cloudflare Zone ID read -p "Enter your Cloudflare Zone ID: " cf_zone_id - if [ ! -z "$cf_zone_id" ]; then - # Basic validation for Zone ID format - if [[ "$cf_zone_id" =~ ^[a-f0-9]{32}$ ]]; then - update_env_var "CF_ZONE_ID" "$cf_zone_id" - echo "✅ Cloudflare Zone ID updated" - else - echo "⚠️ Warning: Zone ID format seems incorrect (should be 32 hex characters)" - update_env_var "CF_ZONE_ID" "$cf_zone_id" - fi - else - echo "⚠️ Cloudflare Zone ID left unchanged" + while [ -z "$cf_zone_id" ] || [ "$cf_zone_id" == "your_cloudflare_zone_id" ]; do + echo "Zone ID is required. Please enter a valid Zone ID." + read -p "Enter your Cloudflare Zone ID: " cf_zone_id + done + + # Optional: Get Account ID now + read -p "Enter your Cloudflare Account ID (optional, can be added later): " cf_account_id + + # Update .env file with Cloudflare credentials + update_env_var "CF_API_TOKEN" "$cf_api_token" + update_env_var "CF_ZONE_ID" "$cf_zone_id" + update_env_var "CF_DOMAIN" "$domain_name" + + if [ ! -z "$cf_account_id" ]; then + update_env_var "CF_ACCOUNT_ID" "$cf_account_id" fi - # CF Tunnel ID - read -p "Enter your Cloudflare Tunnel ID: " cf_tunnel_id - if [ ! -z "$cf_tunnel_id" ]; then - # Basic validation for Tunnel ID format (UUID) - if [[ "$cf_tunnel_id" =~ ^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$ ]]; then - update_env_var "CF_TUNNEL_ID" "$cf_tunnel_id" - echo "✅ Cloudflare Tunnel ID updated" - - # Create tunnel configuration with the provided tunnel ID - create_tunnel_config "$domain_name" "$cf_tunnel_id" - else - echo "⚠️ Warning: Tunnel ID format seems incorrect (should be UUID format)" - update_env_var "CF_TUNNEL_ID" "$cf_tunnel_id" - - # Still create the config file even with potentially incorrect format - create_tunnel_config "$domain_name" "$cf_tunnel_id" - fi - else - echo "⚠️ Cloudflare Tunnel ID left unchanged" - # Create template config without tunnel ID - create_tunnel_config "$domain_name" "\${CF_TUNNEL_ID}" - fi - - echo "" - echo "Cloudflare configuration completed!" - echo "You can now run './add-cname-records.sh' to set up DNS records." - - # Show tunnel setup instructions - show_tunnel_instructions "$domain_name" + echo "Cloudflare credentials saved successfully!" else - echo "Skipping Cloudflare configuration. You can run this script again later to configure it." - # Still create a template tunnel config - echo "" - read -p "Do you want to create a template tunnel configuration anyway? [Y/n]: " create_template - if [[ ! "$create_template" =~ ^[Nn]$ ]]; then - create_tunnel_config "$domain_name" "\${CF_TUNNEL_ID}" - echo "Template tunnel configuration created. Update CF_TUNNEL_ID in .env and regenerate if needed." - fi + echo "Skipping Cloudflare configuration. You can configure it later by editing the .env file." fi # Update the site_url in mkdocs.yml @@ -800,6 +631,10 @@ update_services_yaml "$domain_name" echo -e "\nUpdating login URL in main.html..." update_main_html "$domain_name" +# Update the tunnel configuration file +echo -e "\nUpdating tunnel configuration..." +update_tunnel_config "$domain_name" + # Listmonk Admin Credentials configuration echo -e "\n---- Listmonk Admin Credentials ----" read -p "Enter Listmonk admin email/username [default: admin@example.com]: " listmonk_user @@ -877,8 +712,24 @@ if [[ ! "$configure_cf" =~ ^[Nn]$ ]]; then fi echo -e "\nYour .env file is located at: $ENV_FILE" echo "A backup of your original .env file was created before modifications." -echo -e "\nNext steps:" -echo "1. Run 'docker-compose up -d' to start your services" -if [[ ! "$configure_cf" =~ ^[Nn]$ ]]; then - echo "2. Run './add-cname-records.sh' to set up DNS records and access policies" -fi +echo "" +echo "======================================" +echo "Next Steps:" +echo "======================================" +echo "" +echo "1. Start services locally:" +echo " docker compose up -d" +echo "" +echo "2. Test all services at:" +echo " - Homepage: http://localhost:${HOMEPAGE_PORT:-3010}" +echo " - Code Server: http://localhost:${CODE_SERVER_PORT:-8888}" +echo " - Listmonk: http://localhost:${LISTMONK_PORT:-9000}" +echo " - Documentation: http://localhost:${MKDOCS_PORT:-4000}" +echo " - n8n: http://localhost:${N8N_PORT:-5678}" +echo " - NocoDB: http://localhost:${NOCODB_PORT:-8090}" +echo " - Gitea: http://localhost:${GITEA_WEB_PORT:-3030}" +echo "" +echo "3. When ready for production:" +echo " ./start-production.sh" +echo "" +echo "======================================" \ No newline at end of file diff --git a/configs/cloudflare/tunnel-config.yml b/configs/cloudflare/tunnel-config.yml index 4f28d65..eb0639b 100644 --- a/configs/cloudflare/tunnel-config.yml +++ b/configs/cloudflare/tunnel-config.yml @@ -2,32 +2,32 @@ # Cloudflare Tunnel Configuration # Auto-generated by Changemaker Configuration Wizard -tunnel: ${CF_TUNNEL_ID} # e.g. 1234567890abcdef -credentials-file: /home/coder/.cloudflared/${CF_TUNNEL_ID}.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json +tunnel: your_cloudflared_tunnel_id} # e.g. 1234567890abcdef +credentials-file: /home/coder/.cloudflared/your_cloudflared_tunnel_id}.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json ingress: - - hostname: homepage.test.com + - hostname: homepage.cmlite.org service: http://localhost:3010 - - hostname: code.test.com + - hostname: code.cmlite.org service: http://localhost:8888 - - hostname: listmonk.test.com + - hostname: listmonk.cmlite.org service: http://localhost:9001 - - hostname: docs.test.com + - hostname: docs.cmlite.org service: http://localhost:4000 - - hostname: test.com + - hostname: cmlite.org service: http://localhost:4002 - - hostname: n8n.test.com + - hostname: n8n.cmlite.org service: http://localhost:5678 - - hostname: db.test.com + - hostname: db.cmlite.org service: http://localhost:8090 - - hostname: git.test.com + - hostname: git.cmlite.org service: http://localhost:3030 # Catch-all rule (required) diff --git a/configs/cloudflare/tunnel-config.yml.backup_20250629_154241 b/configs/cloudflare/tunnel-config.yml.backup_20250629_154241 new file mode 100644 index 0000000..4f28d65 --- /dev/null +++ b/configs/cloudflare/tunnel-config.yml.backup_20250629_154241 @@ -0,0 +1,34 @@ +# filepath: /home/bunker-admin/changemaker.lite/configs/cloudflare/tunnel-config.yml +# Cloudflare Tunnel Configuration +# Auto-generated by Changemaker Configuration Wizard + +tunnel: ${CF_TUNNEL_ID} # e.g. 1234567890abcdef +credentials-file: /home/coder/.cloudflared/${CF_TUNNEL_ID}.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json +ingress: + + - hostname: homepage.test.com + service: http://localhost:3010 + + - hostname: code.test.com + service: http://localhost:8888 + + - hostname: listmonk.test.com + service: http://localhost:9001 + + - hostname: docs.test.com + service: http://localhost:4000 + + - hostname: test.com + service: http://localhost:4002 + + - hostname: n8n.test.com + service: http://localhost:5678 + + - hostname: db.test.com + service: http://localhost:8090 + + - hostname: git.test.com + service: http://localhost:3030 + + # Catch-all rule (required) + - service: http_status:404 diff --git a/configs/cloudflare/tunnel-config.yml.backup_20250629_154929 b/configs/cloudflare/tunnel-config.yml.backup_20250629_154929 new file mode 100644 index 0000000..1e29c9d --- /dev/null +++ b/configs/cloudflare/tunnel-config.yml.backup_20250629_154929 @@ -0,0 +1,34 @@ +# filepath: /home/bunker-admin/changemaker.lite/configs/cloudflare/tunnel-config.yml +# Cloudflare Tunnel Configuration +# Auto-generated by Changemaker Configuration Wizard + +tunnel: ${CF_TUNNEL_ID} # e.g. 1234567890abcdef +credentials-file: /home/coder/.cloudflared/${CF_TUNNEL_ID}.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json +ingress: + + - hostname: cmlite.org + service: http://localhost:3010 + + - hostname: cmlite.org + service: http://localhost:3010 + + - hostname: cmlite.org + service: http://localhost:3010 + + - hostname: cmlite.org + service: http://localhost:3010 + + - hostname: cmlite.org + service: http://localhost:3010 + + - hostname: cmlite.org + service: http://localhost:3010 + + - hostname: cmlite.org + service: http://localhost:3010 + + - hostname: cmlite.org + service: http://localhost:3010 + + # Catch-all rule (required) + - service: http_status:404 diff --git a/configs/homepage/services.yaml b/configs/homepage/services.yaml index ea833ac..3c72435 100644 --- a/configs/homepage/services.yaml +++ b/configs/homepage/services.yaml @@ -4,7 +4,7 @@ - Essential Tools: - Code Server: href: "http://localhost:8888" - # href: "https://code.albertademocracytaskforce.org" # Uncomment for public access + # href: "https://cmlite.org" # Uncomment for public access description: VS Code in the browser icon: mdi-code-braces widget: @@ -13,7 +13,7 @@ server: my-docker - Listmonk: href: "http://localhost:9000" - # href: "https://listmonk.albertademocracytaskforce.org" # Uncomment for public access + # href: "https://cmlite.org" # Uncomment for public access description: Newsletter & mailing list manager icon: mdi-email-newsletter widget: @@ -22,7 +22,7 @@ server: my-docker - NocoDB: href: "http://localhost:8090" - # href: "https://db.albertademocracytaskforce.org" # Uncomment for public access + # href: "https://cmlite.org" # Uncomment for public access description: No-code database platform icon: mdi-database widget: @@ -31,7 +31,7 @@ server: my-docker - Gitea: href: "http://localhost:3030" - # href: "https://git.albertademocracytaskforce.org" # Uncomment for public access + # href: "https://cmlite.org" # Uncomment for public access description: Git repository hosting icon: mdi-git widget: @@ -42,7 +42,7 @@ - Content & Documentation: - MkDocs (Live): href: "http://localhost:4000" - # href: "https://docs.albertademocracytaskforce.org" # Uncomment for public access + # href: "https://cmlite.org" # Uncomment for public access description: Live documentation server with hot reload icon: mdi-book-open-page-variant widget: @@ -51,7 +51,7 @@ server: my-docker - Static Site: href: "http://localhost:4001" - # href: "https://albertademocracytaskforce.org" # Uncomment for public access + # href: "https://cmlite.org" # Uncomment for public access description: Built documentation hosting icon: mdi-web widget: @@ -62,7 +62,7 @@ - Automation & Infrastructure: - n8n: href: "http://localhost:5678" - # href: "https://n8n.albertademocracytaskforce.org" # Uncomment for public access + # href: "https://cmlite.org" # Uncomment for public access description: Workflow automation platform icon: mdi-workflow widget: diff --git a/configs/homepage/services.yaml.backup_20250602_184336 b/configs/homepage/services.yaml.backup_20250629_154241 similarity index 100% rename from configs/homepage/services.yaml.backup_20250602_184336 rename to configs/homepage/services.yaml.backup_20250629_154241 diff --git a/configs/homepage/services.yaml.backup_20250629_154929 b/configs/homepage/services.yaml.backup_20250629_154929 new file mode 100644 index 0000000..ea833ac --- /dev/null +++ b/configs/homepage/services.yaml.backup_20250629_154929 @@ -0,0 +1,87 @@ +--- +# For public access, replace "http://localhost" with your subdomain URLs + +- Essential Tools: + - Code Server: + href: "http://localhost:8888" + # href: "https://code.albertademocracytaskforce.org" # Uncomment for public access + description: VS Code in the browser + icon: mdi-code-braces + widget: + type: docker + container: code-server-changemaker + server: my-docker + - Listmonk: + href: "http://localhost:9000" + # href: "https://listmonk.albertademocracytaskforce.org" # Uncomment for public access + description: Newsletter & mailing list manager + icon: mdi-email-newsletter + widget: + type: docker + container: listmonk_app + server: my-docker + - NocoDB: + href: "http://localhost:8090" + # href: "https://db.albertademocracytaskforce.org" # Uncomment for public access + description: No-code database platform + icon: mdi-database + widget: + type: docker + container: changemakerlite-nocodb-1 + server: my-docker + - Gitea: + href: "http://localhost:3030" + # href: "https://git.albertademocracytaskforce.org" # Uncomment for public access + description: Git repository hosting + icon: mdi-git + widget: + type: docker + container: gitea_changemaker + server: my-docker + +- Content & Documentation: + - MkDocs (Live): + href: "http://localhost:4000" + # href: "https://docs.albertademocracytaskforce.org" # Uncomment for public access + description: Live documentation server with hot reload + icon: mdi-book-open-page-variant + widget: + type: docker + container: mkdocs-changemaker + server: my-docker + - Static Site: + href: "http://localhost:4001" + # href: "https://albertademocracytaskforce.org" # Uncomment for public access + description: Built documentation hosting + icon: mdi-web + widget: + type: docker + container: mkdocs-site-server-changemaker + server: my-docker + +- Automation & Infrastructure: + - n8n: + href: "http://localhost:5678" + # href: "https://n8n.albertademocracytaskforce.org" # Uncomment for public access + description: Workflow automation platform + icon: mdi-workflow + widget: + type: docker + container: n8n-changemaker + server: my-docker + - PostgreSQL (Listmonk): + href: "#" + description: Database for Listmonk + icon: mdi-database-outline + widget: + type: docker + container: listmonk_db + server: my-docker + - PostgreSQL (NocoDB): + href: "#" + description: Database for NocoDB + icon: mdi-database-outline + widget: + type: docker + container: changemakerlite-root_db-1 + server: my-docker diff --git a/docker-compose.yml b/docker-compose.yml index ce44715..c0035b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -83,7 +83,7 @@ services: - "${MKDOCS_PORT:-4000}:8000" environment: - SITE_URL=${BASE_DOMAIN:-https://changeme.org} - command: serve --dev-addr=0.0.0.0:8000 --watch-theme --livereload + command: serve --dev-addr=0.0.0.0:8000 --watch-theme --livereload --dirty networks: - changemaker-lite restart: unless-stopped @@ -230,6 +230,26 @@ services: timeout: 5s retries: 5 + # Cloudflare Tunnel (uncommented by start-production.sh) + # cloudflared: + # image: cloudflare/cloudflared:latest + # container_name: cloudflared-changemaker + # restart: unless-stopped + # command: tunnel run + # environment: + # - TUNNEL_TOKEN=${CF_TUNNEL_TOKEN} + # networks: + # - changemaker-lite + # depends_on: + # - homepage-changemaker + # - code-server + # - listmonk-app + # - mkdocs + # - mkdocs-site-server + # - n8n + # - nocodb + # - gitea-app + networks: changemaker-lite: driver: bridge diff --git a/map/.gitignore b/map/.gitignore new file mode 100644 index 0000000..bb296af --- /dev/null +++ b/map/.gitignore @@ -0,0 +1,29 @@ +# Dependencies +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Environment files +.env +.env.local +.env.*.local + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS files +.DS_Store +Thumbs.db + +# Logs +logs/ +*.log + +# Build outputs +dist/ +build/ diff --git a/map/README.md b/map/README.md new file mode 100644 index 0000000..37521ea --- /dev/null +++ b/map/README.md @@ -0,0 +1,142 @@ +# NocoDB Map Viewer + +A containerized web application that visualizes geographic data from NocoDB on an interactive map using Leaflet.js. + +## Features + +- 🗺️ Interactive map visualization with OpenStreetMap +- 📍 Real-time geolocation support +- ➕ Add new locations directly from the map +- 🔄 Auto-refresh every 30 seconds +- 📱 Responsive design for mobile devices +- 🔒 Secure API proxy to protect credentials +- 🐳 Docker containerization for easy deployment +- 🆓 100% open source (no proprietary dependencies) + +## Quick Start + +### Prerequisites + +- Docker and Docker Compose +- NocoDB instance with a table containing location data +- NocoDB API token + +### NocoDB Table Setup + +1. Create a table in NocoDB with these required columns: + - `geodata` (Text): Format "latitude;longitude" + - `latitude` (Decimal): Precision 10, Scale 8 + - `longitude` (Decimal): Precision 11, Scale 8 + +2. Optional recommended columns: + - `title` (Text): Location name + - `description` (Long Text): Details + - `category` (Single Select): Classification + +### Installation + +1. Clone this repository or create the file structure as shown + +2. Copy the environment template: + ```bash + cp .env.example .env + ``` + +3. Edit `.env` with your NocoDB details: + ```env + NOCODB_API_URL=https://db.lindalindsay.org/api/v1 + NOCODB_API_TOKEN=your-token-here + NOCODB_VIEW_URL=https://db.lindalindsay.org/dashboard/#/nc/p406kno3lbq4zmq/mvtryxrvze6td79 + ``` + +4. Start the application: + ```bash + docker-compose up -d + ``` + +5. Access the map at: http://localhost:3000 + +## Finding NocoDB IDs + +### API Token +1. Click user icon → Account Settings +2. Go to "API Tokens" tab +3. Create new token with read/write permissions + +### Project and Table IDs +- Simply provide the full NocoDB view URL in `NOCODB_VIEW_URL` +- The system will automatically extract the project and table IDs + +## API Endpoints + +- `GET /api/locations` - Fetch all locations +- `POST /api/locations` - Create new location +- `GET /api/locations/:id` - Get single location +- `PUT /api/locations/:id` - Update location +- `DELETE /api/locations/:id` - Delete location +- `GET /health` - Health check + +## Configuration + +All configuration is done via environment variables: + +| Variable | Description | Default | +|----------|-------------|---------| +| `NOCODB_API_URL` | NocoDB API base URL | Required | +| `NOCODB_API_TOKEN` | API authentication token | Required | +| `NOCODB_VIEW_URL` | Full NocoDB view URL | Required | +| `PORT` | Server port | 3000 | +| `DEFAULT_LAT` | Default map latitude | 53.5461 | +| `DEFAULT_LNG` | Default map longitude | -113.4938 | +| `DEFAULT_ZOOM` | Default map zoom level | 11 | + +## Development + +To run in development mode: + +1. Install dependencies: + ```bash + cd app + npm install + ``` + +2. Start with hot reload: + ```bash + npm run dev + ``` + +## Security Considerations + +- API tokens are kept server-side only +- CORS is configured for security +- Rate limiting prevents abuse +- Input validation on all endpoints +- Helmet.js for security headers + +## Troubleshooting + +### Locations not showing +- Verify table has `geodata`, `latitude`, and `longitude` columns +- Check that coordinates are valid numbers +- Ensure API token has read permissions + +### Cannot add locations +- Verify API token has write permissions +- Check browser console for errors +- Ensure coordinates are within valid ranges + +### Connection errors +- Verify NocoDB instance is accessible +- Check API URL format +- Confirm network connectivity + +## License + +MIT License - See LICENSE file for details + +## Support + +For issues or questions: +1. Check the troubleshooting section +2. Review NocoDB documentation +3. Open an issue on GitHub diff --git a/map/app/Dockerfile b/map/app/Dockerfile new file mode 100644 index 0000000..a4200cd --- /dev/null +++ b/map/app/Dockerfile @@ -0,0 +1,41 @@ +# Build stage +FROM node:18-alpine AS builder + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm ci --only=production && npm cache clean --force + +# Runtime stage +FROM node:18-alpine + +# Install wget for healthcheck +RUN apk add --no-cache wget + +WORKDIR /app + +# Copy dependencies from builder +COPY --from=builder /app/node_modules ./node_modules + +# Copy application files +COPY package*.json ./ +COPY server.js ./ +COPY public ./public +COPY routes ./routes +COPY services ./services + +# Create non-root user +RUN addgroup -g 1001 -S nodejs && \ + adduser -S nodejs -u 1001 + +# Change ownership +RUN chown -R nodejs:nodejs /app + +USER nodejs + +EXPOSE 3000 + +CMD ["node", "server.js"] diff --git a/map/app/package-lock.json b/map/app/package-lock.json new file mode 100644 index 0000000..4e2f404 --- /dev/null +++ b/map/app/package-lock.json @@ -0,0 +1,1732 @@ +{ + "name": "nocodb-map-viewer", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "nocodb-map-viewer", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "axios": "^1.6.0", + "cookie-parser": "^1.4.7", + "cors": "^2.8.5", + "dotenv": "^16.3.1", + "express": "^4.18.2", + "express-rate-limit": "^7.1.4", + "express-session": "^1.18.1", + "helmet": "^7.1.0", + "winston": "^3.11.0" + }, + "devDependencies": { + "nodemon": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@colors/colors": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", + "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "license": "MIT", + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/@dabh/diagnostics": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz", + "integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==", + "license": "MIT", + "dependencies": { + "colorspace": "1.1.x", + "enabled": "2.0.x", + "kuler": "^2.0.0" + } + }, + "node_modules/@types/triple-beam": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", + "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==", + "license": "MIT" + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz", + "integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/color": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", + "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.3", + "color-string": "^1.6.0" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "license": "MIT" + }, + "node_modules/color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "license": "MIT", + "dependencies": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, + "node_modules/colorspace": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz", + "integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==", + "license": "MIT", + "dependencies": { + "color": "^3.1.3", + "text-hex": "1.0.x" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-parser": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", + "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", + "license": "MIT", + "dependencies": { + "cookie": "0.7.2", + "cookie-signature": "1.0.6" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/cookie-parser/node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz", + "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/enabled": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", + "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.3", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.7.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.3.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.12", + "proxy-addr": "~2.0.7", + "qs": "6.13.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.19.0", + "serve-static": "1.16.2", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-rate-limit": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", + "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, + "node_modules/express-session": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.18.1.tgz", + "integrity": "sha512-a5mtTqEaZvBCL9A9aqkrtfz+3SMDhOVUnjafjo+s7A9Txkq+SVX2DLvSp1Zrv4uCXa3lMSK3viWnh9Gg07PBUA==", + "license": "MIT", + "dependencies": { + "cookie": "0.7.2", + "cookie-signature": "1.0.7", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-headers": "~1.0.2", + "parseurl": "~1.3.3", + "safe-buffer": "5.2.1", + "uid-safe": "~2.1.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/express-session/node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express-session/node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/fecha": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", + "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==", + "license": "MIT" + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fn.name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", + "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", + "license": "MIT" + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz", + "integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/helmet": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-7.2.0.tgz", + "integrity": "sha512-ZRiwvN089JfMXokizgqEPXsl2Guk094yExfoDXR0cBYWxtBbaSww/w+vT4WEJsBW2iTUi1GgZ6swmoug3Oy4Xw==", + "license": "MIT", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "license": "MIT", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true, + "license": "ISC" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", + "license": "MIT" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/kuler": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", + "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", + "license": "MIT" + }, + "node_modules/logform": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.7.0.tgz", + "integrity": "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==", + "license": "MIT", + "dependencies": { + "@colors/colors": "1.6.0", + "@types/triple-beam": "^1.3.2", + "fecha": "^4.2.0", + "ms": "^2.1.1", + "safe-stable-stringify": "^2.3.1", + "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, + "node_modules/logform/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nodemon": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz", + "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/one-time": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", + "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", + "license": "MIT", + "dependencies": { + "fn.name": "1.x.x" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "license": "MIT" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true, + "license": "MIT" + }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.19.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.3.1" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/text-hex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", + "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", + "license": "MIT" + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/triple-beam": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", + "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==", + "license": "MIT", + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "license": "MIT", + "dependencies": { + "random-bytes": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true, + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/winston": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.17.0.tgz", + "integrity": "sha512-DLiFIXYC5fMPxaRg832S6F5mJYvePtmO5G9v9IgUFPhXm9/GkXarH/TUrBAVzhTCzAj9anE/+GjrgXp/54nOgw==", + "license": "MIT", + "dependencies": { + "@colors/colors": "^1.6.0", + "@dabh/diagnostics": "^2.0.2", + "async": "^3.2.3", + "is-stream": "^2.0.0", + "logform": "^2.7.0", + "one-time": "^1.0.0", + "readable-stream": "^3.4.0", + "safe-stable-stringify": "^2.3.1", + "stack-trace": "0.0.x", + "triple-beam": "^1.3.0", + "winston-transport": "^4.9.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, + "node_modules/winston-transport": { + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.9.0.tgz", + "integrity": "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A==", + "license": "MIT", + "dependencies": { + "logform": "^2.7.0", + "readable-stream": "^3.6.2", + "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 12.0.0" + } + } + } +} diff --git a/map/app/package.json b/map/app/package.json new file mode 100644 index 0000000..7ac5132 --- /dev/null +++ b/map/app/package.json @@ -0,0 +1,37 @@ +{ + "name": "nocodb-map-viewer", + "version": "1.0.0", + "description": "Interactive map viewer for NocoDB geographic data", + "main": "server.js", + "scripts": { + "start": "node server.js", + "dev": "nodemon server.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "nocodb", + "map", + "leaflet", + "gis", + "location" + ], + "author": "", + "license": "MIT", + "dependencies": { + "axios": "^1.6.0", + "cookie-parser": "^1.4.7", + "cors": "^2.8.5", + "dotenv": "^16.3.1", + "express": "^4.18.2", + "express-rate-limit": "^7.1.4", + "express-session": "^1.18.1", + "helmet": "^7.1.0", + "winston": "^3.11.0" + }, + "devDependencies": { + "nodemon": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } +} diff --git a/map/app/public/css/style.css b/map/app/public/css/style.css new file mode 100644 index 0000000..99f4755 --- /dev/null +++ b/map/app/public/css/style.css @@ -0,0 +1,628 @@ +/* CSS Variables for theming */ +:root { + --primary-color: #2c5aa0; + --success-color: #27ae60; + --danger-color: #e74c3c; + --warning-color: #f39c12; + --secondary-color: #95a5a6; + --dark-color: #2c3e50; + --light-color: #ecf0f1; + --border-radius: 4px; + --transition: all 0.3s ease; + --header-height: 60px; +} + +/* Reset and base styles */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 1.5; + color: var(--dark-color); + background-color: var(--light-color); +} + +/* App container */ +#app { + display: flex; + flex-direction: column; + height: 100vh; + position: relative; +} + +/* Header */ +.header { + height: var(--header-height); + background-color: var(--dark-color); + color: white; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 20px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + z-index: 1000; +} + +.header h1 { + font-size: 24px; + font-weight: 600; +} + +.header-actions { + display: flex; + align-items: center; + gap: 15px; +} + +.location-count { + background-color: rgba(255,255,255,0.1); + padding: 5px 15px; + border-radius: 20px; + font-size: 14px; +} + +/* User info in header */ +.user-info { + display: flex; + align-items: center; + gap: 15px; + padding: 0 15px; + border-right: 1px solid rgba(255,255,255,0.2); + margin-right: 15px; +} + +.user-email { + font-size: 14px; + color: rgba(255,255,255,0.9); +} + +/* Map container */ +#map-container { + flex: 1; + position: relative; + overflow: hidden; +} + +#map { + width: 100%; + height: 100%; + background-color: #f0f0f0; +} + +/* Map controls */ +.map-controls { + position: absolute; + top: 20px; + right: 20px; + display: flex; + flex-direction: column; + gap: 10px; + z-index: 1000; +} + +/* Buttons */ +.btn { + padding: 10px 16px; + border: none; + border-radius: var(--border-radius); + font-size: 14px; + font-weight: 500; + cursor: pointer; + transition: var(--transition); + display: inline-flex; + align-items: center; + gap: 5px; + white-space: nowrap; + outline: none; +} + +.btn:hover { + transform: translateY(-1px); + box-shadow: 0 4px 8px rgba(0,0,0,0.15); +} + +.btn:active { + transform: translateY(0); +} + +.btn-primary { + background-color: var(--primary-color); + color: white; +} + +.btn-primary:hover { + background-color: #2471a3; +} + +.btn-success { + background-color: var(--success-color); + color: white; +} + +.btn-success:hover { + background-color: #229954; +} + +.btn-secondary { + background-color: var(--secondary-color); + color: white; +} + +.btn-secondary:hover { + background-color: #7f8c8d; +} + +.btn-sm { + padding: 6px 12px; + font-size: 13px; +} + +.btn-danger { + background-color: var(--danger-color); + color: white; +} + +.btn-danger:hover { + background-color: #c0392b; +} + +/* Crosshair for location selection */ +.crosshair { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + pointer-events: none; + z-index: 999; +} + +.crosshair.hidden { + display: none; +} + +.crosshair-x, +.crosshair-y { + position: absolute; + background-color: rgba(44, 90, 160, 0.8); +} + +.crosshair-x { + width: 40px; + height: 2px; + left: -20px; + top: -1px; +} + +.crosshair-y { + width: 2px; + height: 40px; + left: -1px; + top: -20px; +} + +.crosshair-info { + position: absolute; + top: 30px; + left: 50%; + transform: translateX(-50%); + background-color: rgba(44, 62, 80, 0.9); + color: white; + padding: 5px 10px; + border-radius: var(--border-radius); + font-size: 12px; + white-space: nowrap; +} + +/* Status messages */ +.status-container { + position: fixed; + top: calc(var(--header-height) + 20px); + left: 50%; + transform: translateX(-50%); + z-index: 2000; + max-width: 400px; + width: 90%; +} + +.status-message { + padding: 12px 20px; + border-radius: var(--border-radius); + margin-bottom: 10px; + display: flex; + align-items: center; + gap: 10px; + animation: slideIn 0.3s ease; + box-shadow: 0 2px 8px rgba(0,0,0,0.1); +} + +@keyframes slideIn { + from { + opacity: 0; + transform: translateY(-20px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +.status-message.success { + background-color: var(--success-color); + color: white; +} + +.status-message.error { + background-color: var(--danger-color); + color: white; +} + +.status-message.warning { + background-color: var(--warning-color); + color: white; +} + +.status-message.info { + background-color: var(--primary-color); + color: white; +} + +/* Modal */ +.modal { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0,0,0,0.5); + display: flex; + align-items: center; + justify-content: center; + z-index: 3000; + animation: fadeIn 0.3s ease; +} + +.modal.hidden { + display: none; +} + +@keyframes fadeIn { + from { opacity: 0; } + to { opacity: 1; } +} + +.modal-content { + background-color: white; + border-radius: var(--border-radius); + width: 90%; + max-width: 500px; + max-height: 90vh; + overflow: auto; + box-shadow: 0 4px 20px rgba(0,0,0,0.15); + animation: slideUp 0.3s ease; +} + +@keyframes slideUp { + from { + opacity: 0; + transform: translateY(50px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +.modal-header { + padding: 20px; + border-bottom: 1px solid #e0e0e0; + display: flex; + justify-content: space-between; + align-items: center; +} + +.modal-header h2 { + font-size: 20px; + font-weight: 600; + color: var(--dark-color); +} + +.modal-close { + background: none; + border: none; + font-size: 24px; + cursor: pointer; + color: var(--secondary-color); + width: 30px; + height: 30px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 50%; + transition: var(--transition); +} + +.modal-close:hover { + background-color: var(--light-color); + color: var(--dark-color); +} + +.modal-body { + padding: 20px; +} + +/* Edit Footer Form */ +.edit-footer { + position: fixed; + bottom: 0; + left: 0; + right: 0; + background-color: white; + border-top: 2px solid var(--primary-color); + box-shadow: 0 -2px 10px rgba(0,0,0,0.1); + z-index: 1500; + transition: transform 0.3s ease; + max-height: 60vh; + overflow-y: auto; +} + +.edit-footer.hidden { + transform: translateY(100%); +} + +.edit-footer-content { + padding: 20px; + max-width: 800px; + margin: 0 auto; +} + +.edit-footer-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 20px; + padding-bottom: 15px; + border-bottom: 1px solid #e0e0e0; +} + +.edit-footer-header h2 { + margin: 0; + font-size: 20px; + color: var(--dark-color); +} + +/* Form styles */ +.form-group { + margin-bottom: 15px; +} + +.form-row { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 15px; +} + +.form-group label { + display: block; + margin-bottom: 5px; + font-weight: 500; + color: var(--dark-color); + font-size: 14px; +} + +.form-group input, +.form-group textarea { + width: 100%; + padding: 8px 12px; + border: 1px solid #ddd; + border-radius: var(--border-radius); + font-size: 14px; + transition: var(--transition); +} + +.form-group input:focus, +.form-group textarea:focus { + outline: none; + border-color: var(--primary-color); + box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.1); +} + +.form-group input.valid { + border-color: var(--success-color); +} + +.form-group input.invalid { + border-color: var(--danger-color); +} + +.form-group input[readonly] { + background-color: #f5f5f5; + cursor: not-allowed; +} + +.form-group select { + width: 100%; + padding: 8px 12px; + border: 1px solid #ddd; + border-radius: var(--border-radius); + font-size: 14px; + transition: var(--transition); + background-color: white; + cursor: pointer; +} + +.form-group select:focus { + outline: none; + border-color: var(--primary-color); + box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.1); +} + +.form-group input[type="checkbox"] { + width: auto; + margin-right: 8px; + cursor: pointer; +} + +.form-group label input[type="checkbox"] { + vertical-align: middle; +} + +.form-actions { + display: flex; + gap: 10px; + justify-content: flex-end; + margin-top: 20px; + padding-top: 20px; + border-top: 1px solid #e0e0e0; +} + +/* Loading overlay */ +.loading-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(255,255,255,0.9); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + z-index: 4000; +} + +.loading-overlay.hidden { + display: none; +} + +.spinner { + width: 50px; + height: 50px; + border: 3px solid var(--light-color); + border-top-color: var(--primary-color); + border-radius: 50%; + animation: spin 1s linear infinite; +} + +@keyframes spin { + to { transform: rotate(360deg); } +} + +.loading-overlay p { + margin-top: 20px; + color: var(--dark-color); + font-size: 16px; +} + +/* Leaflet customizations */ +.leaflet-popup-content-wrapper { + border-radius: var(--border-radius); + box-shadow: 0 3px 10px rgba(0,0,0,0.2); +} + +.leaflet-popup-content { + margin: 13px 19px; + line-height: 1.5; +} + +.popup-content h3 { + margin: 0 0 10px 0; + color: var(--dark-color); + font-size: 16px; +} + +.popup-content p { + margin: 5px 0; + color: #666; + font-size: 14px; +} + +.popup-content .popup-meta { + font-size: 12px; + color: #999; + margin-top: 10px; + padding-top: 10px; + border-top: 1px solid #eee; +} + +/* Responsive design */ +@media (max-width: 768px) { + .header h1 { + font-size: 20px; + } + + .map-controls { + top: 10px; + right: 10px; + } + + .btn { + padding: 8px 12px; + font-size: 13px; + } + + /* Hide button text on mobile, show only icons */ + .btn span.btn-text { + display: none; + } + + /* Hide user info on mobile to save space */ + .user-info { + display: none; + } + + .btn { + padding: 10px; + min-width: 40px; + min-height: 40px; + justify-content: center; + } + + .modal-content { + width: 95%; + margin: 10px; + } + + .form-row { + grid-template-columns: 1fr; + } +} + +/* Add text spans for desktop that can be hidden on mobile */ +@media (min-width: 769px) { + .btn span.btn-icon { + margin-right: 5px; + } +} + +/* Fullscreen styles */ +.fullscreen #map-container { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 5000; +} + +.fullscreen .header { + display: none; +} + +/* Print styles */ +@media print { + .header, + .map-controls, + .status-container, + .modal { + display: none !important; + } + + #map-container { + height: 100vh; + } +} diff --git a/map/app/public/index.html b/map/app/public/index.html new file mode 100644 index 0000000..5f58530 --- /dev/null +++ b/map/app/public/index.html @@ -0,0 +1,276 @@ + + + + + + + NocoDB Map Viewer + + + + + + + + +
+ +
+

Location Map Viewer

+
+ + Loading... +
+
+ + +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + + + + + +
+
+

Loading map...

+
+
+ + + + + + + + diff --git a/map/app/public/js/map.js b/map/app/public/js/map.js new file mode 100644 index 0000000..7460317 --- /dev/null +++ b/map/app/public/js/map.js @@ -0,0 +1,1051 @@ +// Global configuration +const CONFIG = { + DEFAULT_LAT: parseFloat(document.querySelector('meta[name="default-lat"]')?.content) || 53.5461, + DEFAULT_LNG: parseFloat(document.querySelector('meta[name="default-lng"]')?.content) || -113.4938, + DEFAULT_ZOOM: parseInt(document.querySelector('meta[name="default-zoom"]')?.content) || 11, + REFRESH_INTERVAL: 30000, // 30 seconds + MAX_ZOOM: 19, + MIN_ZOOM: 2 +}; + +// Application state +let map = null; +let markers = []; +let userLocationMarker = null; +let isAddingLocation = false; +let refreshInterval = null; +let currentEditingLocation = null; +let currentUser = null; // Add current user state + +// Initialize application when DOM is loaded +document.addEventListener('DOMContentLoaded', () => { + initializeMap(); + checkAuthentication(); // Add authentication check + loadLocations(); + setupEventListeners(); + checkConfiguration(); + + // Set up auto-refresh + refreshInterval = setInterval(loadLocations, CONFIG.REFRESH_INTERVAL); + + // Add event delegation for dynamically created edit buttons + document.addEventListener('click', function(e) { + if (e.target.classList.contains('edit-location-btn')) { + const locationId = e.target.getAttribute('data-location-id'); + editLocation(locationId); + } + }); +}); + +// Initialize Leaflet map +function initializeMap() { + // Create map instance + map = L.map('map', { + center: [CONFIG.DEFAULT_LAT, CONFIG.DEFAULT_LNG], + zoom: CONFIG.DEFAULT_ZOOM, + zoomControl: true, + attributionControl: true + }); + + // Add OpenStreetMap tiles + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors', + maxZoom: CONFIG.MAX_ZOOM, + minZoom: CONFIG.MIN_ZOOM + }).addTo(map); + + // Add scale control + L.control.scale({ + position: 'bottomleft', + metric: true, + imperial: false + }).addTo(map); + + // Hide loading overlay + document.getElementById('loading').classList.add('hidden'); +} + +// Set up event listeners +function setupEventListeners() { + // Geolocation button + document.getElementById('geolocate-btn').addEventListener('click', handleGeolocation); + + // Add location button + document.getElementById('add-location-btn').addEventListener('click', toggleAddLocation); + + // Refresh button + document.getElementById('refresh-btn').addEventListener('click', () => { + showStatus('Refreshing locations...', 'info'); + loadLocations(); + }); + + // Fullscreen button + document.getElementById('fullscreen-btn').addEventListener('click', toggleFullscreen); + + // Form submission + document.getElementById('location-form').addEventListener('submit', handleLocationSubmit); + + // Edit form submission + document.getElementById('edit-location-form').addEventListener('submit', handleEditLocationSubmit); + + // Map click handler for adding locations + map.on('click', handleMapClick); + + // Set up geo field synchronization + setupGeoFieldSync(); + + // Add event listeners for buttons that were using inline onclick + document.getElementById('close-edit-footer-btn').addEventListener('click', closeEditFooter); + document.getElementById('lookup-address-edit-btn').addEventListener('click', lookupAddressForEdit); + document.getElementById('delete-location-btn').addEventListener('click', deleteLocation); + document.getElementById('close-modal-btn').addEventListener('click', closeModal); + document.getElementById('lookup-address-add-btn').addEventListener('click', lookupAddressForAdd); + document.getElementById('cancel-modal-btn').addEventListener('click', closeModal); +} + +// Helper function to get color based on support level +function getSupportColor(supportLevel) { + const level = parseInt(supportLevel); + switch(level) { + case 1: return '#27ae60'; // Green - Strong support + case 2: return '#f1c40f'; // Yellow - Moderate support + case 3: return '#e67e22'; // Orange - Low support + case 4: return '#e74c3c'; // Red - No support + default: return '#95a5a6'; // Grey - Unknown/null + } +} + +// Helper function to get support level text +function getSupportLevelText(level) { + const levelNum = parseInt(level); + switch(levelNum) { + case 1: return '1 - Strong Support'; + case 2: return '2 - Moderate Support'; + case 3: return '3 - Low Support'; + case 4: return '4 - No Support'; + default: return 'Not Specified'; + } +} + +// Set up geo field synchronization +function setupGeoFieldSync() { + const latInput = document.getElementById('location-lat'); + const lngInput = document.getElementById('location-lng'); + const geoLocationInput = document.getElementById('geo-location'); + + // Validate geo-location format + function validateGeoLocation(value) { + if (!value) return false; + + // Check both formats + const patterns = [ + /^-?\d+\.?\d*\s*,\s*-?\d+\.?\d*$/, // comma-separated + /^-?\d+\.?\d*\s*;\s*-?\d+\.?\d*$/ // semicolon-separated + ]; + + return patterns.some(pattern => pattern.test(value)); + } + + // When lat/lng change, update geo-location + function updateGeoLocation() { + const lat = parseFloat(latInput.value); + const lng = parseFloat(lngInput.value); + + if (!isNaN(lat) && !isNaN(lng)) { + geoLocationInput.value = `${lat};${lng}`; // Use semicolon format for NocoDB + geoLocationInput.classList.remove('invalid'); + geoLocationInput.classList.add('valid'); + } + } + + // When geo-location changes, parse and update lat/lng + function parseGeoLocation() { + const geoValue = geoLocationInput.value.trim(); + + if (!geoValue) { + geoLocationInput.classList.remove('valid', 'invalid'); + return; + } + + if (!validateGeoLocation(geoValue)) { + geoLocationInput.classList.add('invalid'); + geoLocationInput.classList.remove('valid'); + return; + } + + // Try semicolon-separated first + let parts = geoValue.split(';'); + if (parts.length === 2) { + const lat = parseFloat(parts[0].trim()); + const lng = parseFloat(parts[1].trim()); + if (!isNaN(lat) && !isNaN(lng)) { + latInput.value = lat.toFixed(8); + lngInput.value = lng.toFixed(8); + // Keep semicolon format for NocoDB GeoData + geoLocationInput.value = `${lat};${lng}`; + geoLocationInput.classList.add('valid'); + geoLocationInput.classList.remove('invalid'); + return; + } + } + + // Try comma-separated + parts = geoValue.split(','); + if (parts.length === 2) { + const lat = parseFloat(parts[0].trim()); + const lng = parseFloat(parts[1].trim()); + if (!isNaN(lat) && !isNaN(lng)) { + latInput.value = lat.toFixed(8); + lngInput.value = lng.toFixed(8); + // Normalize to semicolon format for NocoDB GeoData + geoLocationInput.value = `${lat};${lng}`; + geoLocationInput.classList.add('valid'); + geoLocationInput.classList.remove('invalid'); + } + } + } + + // Add event listeners + latInput.addEventListener('input', updateGeoLocation); + lngInput.addEventListener('input', updateGeoLocation); + geoLocationInput.addEventListener('blur', parseGeoLocation); + geoLocationInput.addEventListener('input', () => { + // Clear validation classes on input to allow real-time feedback + const geoValue = geoLocationInput.value.trim(); + if (geoValue && validateGeoLocation(geoValue)) { + geoLocationInput.classList.add('valid'); + geoLocationInput.classList.remove('invalid'); + } else if (geoValue) { + geoLocationInput.classList.add('invalid'); + geoLocationInput.classList.remove('valid'); + } else { + geoLocationInput.classList.remove('valid', 'invalid'); + } + }); +} + +// Check authentication and display user info +async function checkAuthentication() { + try { + const response = await fetch('/api/auth/check'); + const data = await response.json(); + + if (data.authenticated && data.user) { + currentUser = data.user; + displayUserInfo(); + } + } catch (error) { + console.error('Failed to check authentication:', error); + } +} + +// Display user info in header +function displayUserInfo() { + const headerActions = document.querySelector('.header-actions'); + + // Create user info element + const userInfo = document.createElement('div'); + userInfo.className = 'user-info'; + userInfo.innerHTML = ` + ${escapeHtml(currentUser.email)} + + `; + + // Insert before the location count + const locationCount = document.getElementById('location-count'); + headerActions.insertBefore(userInfo, locationCount); + + // Add logout event listener + document.getElementById('logout-btn').addEventListener('click', handleLogout); +} + +// Handle logout +async function handleLogout() { + if (!confirm('Are you sure you want to logout?')) { + return; + } + + try { + const response = await fetch('/api/auth/logout', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + } + }); + + if (response.ok) { + window.location.href = '/login.html'; + } else { + showStatus('Logout failed. Please try again.', 'error'); + } + } catch (error) { + console.error('Logout error:', error); + showStatus('Logout failed. Please try again.', 'error'); + } +} + +// Check API configuration +async function checkConfiguration() { + try { + const response = await fetch('/api/config-check'); + const data = await response.json(); + + if (!data.configured) { + showStatus('Warning: API not fully configured. Check your .env file.', 'warning'); + } + } catch (error) { + console.error('Configuration check failed:', error); + } +} + +// Load locations from API +async function loadLocations() { + try { + const response = await fetch('/api/locations'); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const data = await response.json(); + + if (data.success) { + displayLocations(data.locations); + updateLocationCount(data.count); + } else { + throw new Error(data.error || 'Failed to load locations'); + } + + } catch (error) { + console.error('Error loading locations:', error); + showStatus('Failed to load locations. Check your connection.', 'error'); + updateLocationCount(0); + } +} + +// Display locations on map +function displayLocations(locations) { + // Clear existing markers + markers.forEach(marker => map.removeLayer(marker)); + markers = []; + + // Add new markers + locations.forEach(location => { + if (location.latitude && location.longitude) { + const marker = createLocationMarker(location); + markers.push(marker); + } + }); + + // Fit map to show all markers if there are any + if (markers.length > 0) { + const group = new L.featureGroup(markers); + map.fitBounds(group.getBounds().pad(0.1)); + } +} + +// Create marker for location (updated to use circle markers) +function createLocationMarker(location) { + console.log('Creating marker for location:', location); + + // Get color based on support level + const supportColor = getSupportColor(location['Support Level']); + + // Create circle marker instead of default marker + const marker = L.circleMarker([location.latitude, location.longitude], { + radius: 8, + fillColor: supportColor, + color: '#fff', + weight: 2, + opacity: 1, + fillOpacity: 0.8, + title: location.title || 'Location', + riseOnHover: true, + locationData: location // Store location data in marker options + }).addTo(map); + + // Add larger radius on hover + marker.on('mouseover', function() { + this.setRadius(10); + }); + + marker.on('mouseout', function() { + this.setRadius(8); + }); + + // Create popup content + const popupContent = createPopupContent(location); + marker.bindPopup(popupContent); + + return marker; +} + +// Create popup content for marker +function createPopupContent(location) { + console.log('Creating popup for location:', location); + + let content = ''; + + return content; +} + +// Handle geolocation +function handleGeolocation() { + if (!navigator.geolocation) { + showStatus('Geolocation is not supported by your browser', 'error'); + return; + } + + showStatus('Getting your location...', 'info'); + + navigator.geolocation.getCurrentPosition( + (position) => { + const { latitude, longitude, accuracy } = position.coords; + + // Center map on user location + map.setView([latitude, longitude], 15); + + // Remove existing user marker + if (userLocationMarker) { + map.removeLayer(userLocationMarker); + } + + // Add user location marker + userLocationMarker = L.marker([latitude, longitude], { + icon: L.divIcon({ + html: '
', + className: 'user-location-marker', + iconSize: [20, 20], + iconAnchor: [10, 10] + }), + title: 'Your location' + }).addTo(map); + + // Add accuracy circle + L.circle([latitude, longitude], { + radius: accuracy, + color: '#2c5aa0', + fillColor: '#2c5aa0', + fillOpacity: 0.1, + weight: 1 + }).addTo(map); + + showStatus(`Location found (±${Math.round(accuracy)}m accuracy)`, 'success'); + }, + (error) => { + let message = 'Unable to get your location'; + + switch (error.code) { + case error.PERMISSION_DENIED: + message = 'Location permission denied'; + break; + case error.POSITION_UNAVAILABLE: + message = 'Location information unavailable'; + break; + case error.TIMEOUT: + message = 'Location request timed out'; + break; + } + + showStatus(message, 'error'); + }, + { + enableHighAccuracy: true, + timeout: 10000, + maximumAge: 0 + } + ); +} + +// Toggle add location mode +function toggleAddLocation() { + isAddingLocation = !isAddingLocation; + + const btn = document.getElementById('add-location-btn'); + const crosshair = document.getElementById('crosshair'); + + if (isAddingLocation) { + btn.innerHTML = 'Cancel'; + btn.classList.remove('btn-success'); + btn.classList.add('btn-secondary'); + crosshair.classList.remove('hidden'); + map.getContainer().style.cursor = 'crosshair'; + } else { + btn.innerHTML = 'Add Location Here'; + btn.classList.remove('btn-secondary'); + btn.classList.add('btn-success'); + crosshair.classList.add('hidden'); + map.getContainer().style.cursor = ''; + } +} + +// Handle map click +function handleMapClick(e) { + if (!isAddingLocation) return; + + const { lat, lng } = e.latlng; + + // Toggle off add location mode + toggleAddLocation(); + + // Show modal with coordinates + showAddLocationModal(lat, lng); +} + +// Show add location modal +function showAddLocationModal(lat, lng) { + const modal = document.getElementById('add-modal'); + const latInput = document.getElementById('location-lat'); + const lngInput = document.getElementById('location-lng'); + const geoLocationInput = document.getElementById('geo-location'); + + // Set coordinates + latInput.value = lat.toFixed(8); + lngInput.value = lng.toFixed(8); + + // Set geo-location field + geoLocationInput.value = `${lat.toFixed(8)};${lng.toFixed(8)}`; // Use semicolon format for NocoDB + geoLocationInput.classList.add('valid'); + geoLocationInput.classList.remove('invalid'); + + // Clear other fields + document.getElementById('first-name').value = ''; + document.getElementById('last-name').value = ''; + document.getElementById('location-email').value = ''; + document.getElementById('location-unit').value = ''; + document.getElementById('support-level').value = ''; + const addressInput = document.getElementById('location-address'); + addressInput.value = 'Looking up address...'; // Show loading message + document.getElementById('sign').checked = false; + document.getElementById('sign-size').value = ''; + + // Show modal + modal.classList.remove('hidden'); + + // Fetch address asynchronously + reverseGeocode(lat, lng).then(result => { + if (result) { + addressInput.value = result.formattedAddress || result.fullAddress; + } else { + addressInput.value = ''; // Clear if lookup fails + // Don't show warning for automatic lookups + } + }).catch(error => { + console.error('Address lookup failed:', error); + addressInput.value = ''; + }); + + // Focus on first name input + setTimeout(() => { + document.getElementById('first-name').focus(); + }, 100); +} + +// Close modal +function closeModal() { + document.getElementById('add-modal').classList.add('hidden'); +} + +// Edit location function +function editLocation(locationId) { + // Find the location in markers data + const location = markers.find(m => { + const data = m.options.locationData; + return String(data.id || data.Id) === String(locationId); + })?.options.locationData; + + if (!location) { + console.error('Location not found for ID:', locationId); + console.log('Available locations:', markers.map(m => ({ + id: m.options.locationData.id || m.options.locationData.Id, + name: m.options.locationData['First Name'] + ' ' + m.options.locationData['Last Name'] + }))); + showStatus('Location not found', 'error'); + return; + } + + currentEditingLocation = location; + + // Populate all the edit form fields + document.getElementById('edit-location-id').value = location.id || location.Id || ''; + document.getElementById('edit-first-name').value = location['First Name'] || ''; + document.getElementById('edit-last-name').value = location['Last Name'] || ''; + document.getElementById('edit-location-email').value = location['Email'] || ''; + document.getElementById('edit-location-unit').value = location['Unit Number'] || ''; + document.getElementById('edit-support-level').value = location['Support Level'] || ''; + + const addressInput = document.getElementById('edit-location-address'); + addressInput.value = location['Address'] || ''; + + // If no address exists, try to fetch it + if (!location['Address'] && location.latitude && location.longitude) { + addressInput.value = 'Looking up address...'; + reverseGeocode(location.latitude, location.longitude).then(result => { + if (result && !location['Address']) { + addressInput.value = result.formattedAddress || result.fullAddress; + } else if (!location['Address']) { + addressInput.value = ''; + // Don't show error - just silently fail + } + }).catch(error => { + // Handle any unexpected errors + console.error('Address lookup failed:', error); + addressInput.value = ''; + }); + } + + // Handle checkbox + document.getElementById('edit-sign').checked = location['Sign'] === true || location['Sign'] === 'true' || location['Sign'] === 1; + document.getElementById('edit-sign-size').value = location['Sign Size'] || ''; + + document.getElementById('edit-location-lat').value = location.latitude || ''; + document.getElementById('edit-location-lng').value = location.longitude || ''; + document.getElementById('edit-geo-location').value = location['Geo-Location'] || `${location.latitude};${location.longitude}`; + + // Show the edit footer + document.getElementById('edit-footer').classList.remove('hidden'); + document.getElementById('map-container').classList.add('edit-mode'); + + // Invalidate map size after showing footer + setTimeout(() => map.invalidateSize(), 300); + + // Setup geo field sync for edit form + setupEditGeoFieldSync(); +} + +// Close edit footer +function closeEditFooter() { + document.getElementById('edit-footer').classList.add('hidden'); + document.getElementById('map-container').classList.remove('edit-mode'); + currentEditingLocation = null; + + // Invalidate map size after hiding footer + setTimeout(() => map.invalidateSize(), 300); +} + +// Setup geo field sync for edit form +function setupEditGeoFieldSync() { + const latInput = document.getElementById('edit-location-lat'); + const lngInput = document.getElementById('edit-location-lng'); + const geoLocationInput = document.getElementById('edit-geo-location'); + + // Similar to setupGeoFieldSync but for edit form + function updateGeoLocation() { + const lat = parseFloat(latInput.value); + const lng = parseFloat(lngInput.value); + + if (!isNaN(lat) && !isNaN(lng)) { + geoLocationInput.value = `${lat};${lng}`; + geoLocationInput.classList.remove('invalid'); + geoLocationInput.classList.add('valid'); + } + } + + function parseGeoLocation() { + const geoValue = geoLocationInput.value.trim(); + + if (!geoValue) { + geoLocationInput.classList.remove('valid', 'invalid'); + return; + } + + // Try semicolon-separated first + let parts = geoValue.split(';'); + if (parts.length === 2) { + const lat = parseFloat(parts[0].trim()); + const lng = parseFloat(parts[1].trim()); + if (!isNaN(lat) && !isNaN(lng)) { + latInput.value = lat.toFixed(8); + lngInput.value = lng.toFixed(8); + geoLocationInput.classList.add('valid'); + geoLocationInput.classList.remove('invalid'); + return; + } + } + + // Try comma-separated + parts = geoValue.split(','); + if (parts.length === 2) { + const lat = parseFloat(parts[0].trim()); + const lng = parseFloat(parts[1].trim()); + if (!isNaN(lat) && !isNaN(lng)) { + latInput.value = lat.toFixed(8); + lngInput.value = lng.toFixed(8); + geoLocationInput.value = `${lat};${lng}`; + geoLocationInput.classList.add('valid'); + geoLocationInput.classList.remove('invalid'); + } + } + } + + latInput.addEventListener('input', updateGeoLocation); + lngInput.addEventListener('input', updateGeoLocation); + geoLocationInput.addEventListener('blur', parseGeoLocation); +} + +// Handle edit form submission +async function handleEditLocationSubmit(e) { + e.preventDefault(); + + const formData = new FormData(e.target); + const data = Object.fromEntries(formData); + const locationId = data.id; + + // Ensure Geo-Location field is included + const geoLocationInput = document.getElementById('edit-geo-location'); + if (geoLocationInput.value) { + data['Geo-Location'] = geoLocationInput.value; + } + + try { + const response = await fetch(`/api/locations/${locationId}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }); + + const result = await response.json(); + + if (response.ok && result.success) { + showStatus('Location updated successfully!', 'success'); + closeEditFooter(); + + // Reload locations + loadLocations(); + } else { + throw new Error(result.error || 'Failed to update location'); + } + + } catch (error) { + console.error('Error updating location:', error); + showStatus(error.message, 'error'); + } +} + +// Delete location +async function deleteLocation() { + if (!currentEditingLocation) return; + + const locationId = currentEditingLocation.id || currentEditingLocation.Id; + + if (!confirm('Are you sure you want to delete this location?')) { + return; + } + + try { + const response = await fetch(`/api/locations/${locationId}`, { + method: 'DELETE' + }); + + const result = await response.json(); + + if (response.ok && result.success) { + showStatus('Location deleted successfully!', 'success'); + closeEditFooter(); + + // Reload locations + loadLocations(); + } else { + throw new Error(result.error || 'Failed to delete location'); + } + + } catch (error) { + console.error('Error deleting location:', error); + showStatus(error.message, 'error'); + } +} + +// Handle location form submission +async function handleLocationSubmit(e) { + e.preventDefault(); + + const formData = new FormData(e.target); + const data = Object.fromEntries(formData); + + // Validate required fields - either first name or last name should be provided + if ((!data['First Name'] || !data['First Name'].trim()) && + (!data['Last Name'] || !data['Last Name'].trim())) { + showStatus('Either First Name or Last Name is required', 'error'); + return; + } + + // Ensure Geo-Location field is included + const geoLocationInput = document.getElementById('geo-location'); + if (geoLocationInput.value) { + data['Geo-Location'] = geoLocationInput.value; + } + + try { + const response = await fetch('/api/locations', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }); + + const result = await response.json(); + + if (response.ok && result.success) { + showStatus('Location added successfully!', 'success'); + closeModal(); + + // Reload locations + loadLocations(); + + // Center map on new location + map.setView([data.latitude, data.longitude], map.getZoom()); + } else { + throw new Error(result.error || 'Failed to add location'); + } + + } catch (error) { + console.error('Error adding location:', error); + showStatus(error.message, 'error'); + } +} + +// Toggle fullscreen +function toggleFullscreen() { + const app = document.getElementById('app'); + const btn = document.getElementById('fullscreen-btn'); + + if (!document.fullscreenElement) { + app.requestFullscreen().then(() => { + app.classList.add('fullscreen'); + btn.innerHTML = 'Exit Fullscreen'; + + // Invalidate map size after transition + setTimeout(() => map.invalidateSize(), 300); + }).catch(err => { + showStatus('Unable to enter fullscreen', 'error'); + }); + } else { + document.exitFullscreen().then(() => { + app.classList.remove('fullscreen'); + btn.innerHTML = 'Fullscreen'; + + // Invalidate map size after transition + setTimeout(() => map.invalidateSize(), 300); + }); + } +} + +// Update location count +function updateLocationCount(count) { + const countElement = document.getElementById('location-count'); + countElement.textContent = `${count} location${count !== 1 ? 's' : ''}`; +} + +// Show status message +function showStatus(message, type = 'info') { + const container = document.getElementById('status-container'); + + const messageDiv = document.createElement('div'); + messageDiv.className = `status-message ${type}`; + messageDiv.textContent = message; + + container.appendChild(messageDiv); + + // Auto-remove after 5 seconds + setTimeout(() => { + messageDiv.remove(); + }, 5000); +} + +// Escape HTML to prevent XSS +function escapeHtml(text) { + if (text === null || text === undefined) { + return ''; + } + const div = document.createElement('div'); + div.textContent = String(text); + return div.innerHTML; +} + +// Handle window resize +window.addEventListener('resize', () => { + map.invalidateSize(); +}); + +// Clean up on page unload +window.addEventListener('beforeunload', () => { + if (refreshInterval) { + clearInterval(refreshInterval); + } +}); + +// Reverse geocode to get address from coordinates +async function reverseGeocode(lat, lng) { + try { + const response = await fetch(`/api/geocode/reverse?lat=${lat}&lng=${lng}`); + + if (!response.ok) { + const error = await response.json(); + throw new Error(error.error || 'Geocoding service unavailable'); + } + + const result = await response.json(); + + if (!result.success || !result.data) { + throw new Error('Geocoding failed'); + } + + return result.data; + + } catch (error) { + console.error('Reverse geocoding error:', error); + return null; + } +} + +// Add a new function for forward geocoding (address to coordinates) +async function forwardGeocode(address) { + try { + const response = await fetch(`/api/geocode/forward?address=${encodeURIComponent(address)}`); + + if (!response.ok) { + const error = await response.json(); + throw new Error(error.error || 'Geocoding service unavailable'); + } + + const result = await response.json(); + + if (!result.success || !result.data) { + throw new Error('Geocoding failed'); + } + + return result.data; + + } catch (error) { + console.error('Forward geocoding error:', error); + return null; + } +} + +// Manual address lookup for add form +async function lookupAddressForAdd() { + const latInput = document.getElementById('location-lat'); + const lngInput = document.getElementById('location-lng'); + const addressInput = document.getElementById('location-address'); + + const lat = parseFloat(latInput.value); + const lng = parseFloat(lngInput.value); + + if (!isNaN(lat) && !isNaN(lng)) { + addressInput.value = 'Looking up address...'; + const result = await reverseGeocode(lat, lng); + if (result) { + addressInput.value = result.formattedAddress || result.fullAddress; + showStatus('Address found!', 'success'); + } else { + addressInput.value = ''; + showStatus('Could not find address for these coordinates', 'warning'); + } + } else { + showStatus('Please enter valid coordinates first', 'warning'); + } +} + +// Manual address lookup for edit form +async function lookupAddressForEdit() { + const latInput = document.getElementById('edit-location-lat'); + const lngInput = document.getElementById('edit-location-lng'); + const addressInput = document.getElementById('edit-location-address'); + + const lat = parseFloat(latInput.value); + const lng = parseFloat(lngInput.value); + + if (!isNaN(lat) && !isNaN(lng)) { + addressInput.value = 'Looking up address...'; + const result = await reverseGeocode(lat, lng); + if (result) { + addressInput.value = result.formattedAddress || result.fullAddress; + showStatus('Address found!', 'success'); + } else { + addressInput.value = ''; + showStatus('Could not find address for these coordinates', 'warning'); + } + } else { + showStatus('Please enter valid coordinates first', 'warning'); + } +} diff --git a/map/app/public/login.html b/map/app/public/login.html new file mode 100644 index 0000000..2daa46c --- /dev/null +++ b/map/app/public/login.html @@ -0,0 +1,254 @@ + + + + + + + Login - NocoDB Map Viewer + + + + + + +
+
+ + +
+
+ + + + +
+
+ + + + diff --git a/map/app/routes/geocoding.js b/map/app/routes/geocoding.js new file mode 100644 index 0000000..3d1347d --- /dev/null +++ b/map/app/routes/geocoding.js @@ -0,0 +1,113 @@ +const express = require('express'); +const router = express.Router(); +const rateLimit = require('express-rate-limit'); +const { reverseGeocode, forwardGeocode, getCacheStats } = require('../services/geocoding'); + +// Rate limiter specifically for geocoding endpoints +const geocodeLimiter = rateLimit({ + windowMs: 15 * 60 * 1000, // 15 minutes + max: 30, // limit each IP to 30 requests per windowMs + message: 'Too many geocoding requests, please try again later.' +}); + +/** + * Reverse geocode endpoint + * GET /api/geocode/reverse?lat=&lng= + */ +router.get('/reverse', geocodeLimiter, async (req, res) => { + try { + const { lat, lng } = req.query; + + // Validate input + if (!lat || !lng) { + return res.status(400).json({ + success: false, + error: 'Latitude and longitude are required' + }); + } + + const latitude = parseFloat(lat); + const longitude = parseFloat(lng); + + if (isNaN(latitude) || isNaN(longitude)) { + return res.status(400).json({ + success: false, + error: 'Invalid latitude or longitude' + }); + } + + if (latitude < -90 || latitude > 90 || longitude < -180 || longitude > 180) { + return res.status(400).json({ + success: false, + error: 'Coordinates out of range' + }); + } + + // Perform reverse geocoding + const result = await reverseGeocode(latitude, longitude); + + res.json({ + success: true, + data: result + }); + + } catch (error) { + console.error('Reverse geocoding error:', error); + + const statusCode = error.message.includes('Rate limit') ? 429 : 500; + + res.status(statusCode).json({ + success: false, + error: error.message + }); + } +}); + +/** + * Forward geocode endpoint + * GET /api/geocode/forward?address=
+ */ +router.get('/forward', geocodeLimiter, async (req, res) => { + try { + const { address } = req.query; + + // Validate input + if (!address || address.trim().length === 0) { + return res.status(400).json({ + success: false, + error: 'Address is required' + }); + } + + // Perform forward geocoding + const result = await forwardGeocode(address); + + res.json({ + success: true, + data: result + }); + + } catch (error) { + console.error('Forward geocoding error:', error); + + const statusCode = error.message.includes('Rate limit') ? 429 : 500; + + res.status(statusCode).json({ + success: false, + error: error.message + }); + } +}); + +/** + * Get geocoding cache statistics (admin endpoint) + * GET /api/geocode/cache/stats + */ +router.get('/cache/stats', (req, res) => { + res.json({ + success: true, + data: getCacheStats() + }); +}); + +module.exports = router; diff --git a/map/app/server.js b/map/app/server.js new file mode 100644 index 0000000..dff2e8f --- /dev/null +++ b/map/app/server.js @@ -0,0 +1,801 @@ +const express = require('express'); +const axios = require('axios'); +const cors = require('cors'); +const helmet = require('helmet'); +const rateLimit = require('express-rate-limit'); +const winston = require('winston'); +const path = require('path'); +const session = require('express-session'); +const cookieParser = require('cookie-parser'); +require('dotenv').config(); + +// Import geocoding routes +const geocodingRoutes = require('./routes/geocoding'); + +// Parse project and table IDs from view URL +function parseNocoDBUrl(url) { + if (!url) return { projectId: null, tableId: null }; + + // Pattern to match NocoDB URLs + const patterns = [ + /#\/nc\/([^\/]+)\/([^\/\?#]+)/, // matches #/nc/PROJECT_ID/TABLE_ID (dashboard URLs) + /\/nc\/([^\/]+)\/([^\/\?#]+)/, // matches /nc/PROJECT_ID/TABLE_ID + /project\/([^\/]+)\/table\/([^\/\?#]+)/, // alternative pattern + ]; + + for (const pattern of patterns) { + const match = url.match(pattern); + if (match) { + return { + projectId: match[1], + tableId: match[2] + }; + } + } + + return { projectId: null, tableId: null }; +} + +// Add this helper function near the top of the file after the parseNocoDBUrl function +function syncGeoFields(data) { + // If we have latitude and longitude but no Geo-Location, create it + if (data.latitude && data.longitude && !data['Geo-Location']) { + const lat = parseFloat(data.latitude); + const lng = parseFloat(data.longitude); + if (!isNaN(lat) && !isNaN(lng)) { + data['Geo-Location'] = `${lat};${lng}`; // Use semicolon format for NocoDB GeoData + data.geodata = `${lat};${lng}`; // Also update geodata for compatibility + } + } + + // If we have Geo-Location but no lat/lng, parse it + else if (data['Geo-Location'] && (!data.latitude || !data.longitude)) { + const geoLocation = data['Geo-Location'].toString(); + + // Try semicolon-separated first + let parts = geoLocation.split(';'); + if (parts.length === 2) { + const lat = parseFloat(parts[0].trim()); + const lng = parseFloat(parts[1].trim()); + if (!isNaN(lat) && !isNaN(lng)) { + data.latitude = lat; + data.longitude = lng; + data.geodata = `${lat};${lng}`; + return data; + } + } + + // Try comma-separated + parts = geoLocation.split(','); + if (parts.length === 2) { + const lat = parseFloat(parts[0].trim()); + const lng = parseFloat(parts[1].trim()); + if (!isNaN(lat) && !isNaN(lng)) { + data.latitude = lat; + data.longitude = lng; + data.geodata = `${lat};${lng}`; + // Normalize Geo-Location to semicolon format for NocoDB GeoData + data['Geo-Location'] = `${lat};${lng}`; + } + } + } + + return data; +} + +// Auto-parse IDs if view URL is provided +if (process.env.NOCODB_VIEW_URL && (!process.env.NOCODB_PROJECT_ID || !process.env.NOCODB_TABLE_ID)) { + const { projectId, tableId } = parseNocoDBUrl(process.env.NOCODB_VIEW_URL); + + if (projectId && tableId) { + process.env.NOCODB_PROJECT_ID = projectId; + process.env.NOCODB_TABLE_ID = tableId; + console.log(`Auto-parsed from URL - Project ID: ${projectId}, Table ID: ${tableId}`); + } +} + +// Auto-parse login sheet ID if URL is provided +let LOGIN_SHEET_ID = null; +if (process.env.NOCODB_LOGIN_SHEET) { + // Check if it's a URL or just an ID + if (process.env.NOCODB_LOGIN_SHEET.startsWith('http')) { + const { projectId, tableId } = parseNocoDBUrl(process.env.NOCODB_LOGIN_SHEET); + if (projectId && tableId) { + LOGIN_SHEET_ID = tableId; + console.log(`Auto-parsed login sheet ID from URL: ${LOGIN_SHEET_ID}`); + } else { + console.error('Could not parse login sheet URL'); + } + } else { + // Assume it's already just the ID + LOGIN_SHEET_ID = process.env.NOCODB_LOGIN_SHEET; + console.log(`Using login sheet ID: ${LOGIN_SHEET_ID}`); + } +} + +// Configure logger +const logger = winston.createLogger({ + level: process.env.NODE_ENV === 'production' ? 'info' : 'debug', + format: winston.format.combine( + winston.format.timestamp(), + winston.format.json() + ), + transports: [ + new winston.transports.Console({ + format: winston.format.simple() + }) + ] +}); + +// Initialize Express app +const app = express(); +const PORT = process.env.PORT || 3000; + +// Session configuration +app.use(cookieParser()); + +// Determine if we should use secure cookies based on environment and request +const isProduction = process.env.NODE_ENV === 'production'; + +// Cookie configuration function +const getCookieConfig = (req) => { + const host = req?.get('host') || ''; + const isLocalhost = host.includes('localhost') || host.includes('127.0.0.1') || host.match(/^\d+\.\d+\.\d+\.\d+/); + + const config = { + httpOnly: true, + maxAge: 24 * 60 * 60 * 1000, // 24 hours + sameSite: 'lax', + secure: false, // Default to false + domain: undefined // Default to no domain restriction + }; + + // Only set domain and secure for production non-localhost access + if (isProduction && !isLocalhost && process.env.COOKIE_DOMAIN) { + // Check if the request is coming from a subdomain of COOKIE_DOMAIN + const cookieDomain = process.env.COOKIE_DOMAIN.replace(/^\./, ''); // Remove leading dot + if (host.includes(cookieDomain)) { + config.domain = process.env.COOKIE_DOMAIN; + config.secure = true; + } + } + + return config; +}; + +app.use(session({ + secret: process.env.SESSION_SECRET || 'your-secret-key-change-in-production', + resave: false, + saveUninitialized: false, + cookie: getCookieConfig(), + name: 'nocodb-map-session', + genid: (req) => { + // Use a custom session ID generator to avoid conflicts + return require('crypto').randomBytes(16).toString('hex'); + } +})); + +// Security middleware +app.use(helmet({ + contentSecurityPolicy: { + directives: { + defaultSrc: ["'self'"], + styleSrc: ["'self'", "'unsafe-inline'", "https://unpkg.com"], + scriptSrc: ["'self'", "'unsafe-inline'", "https://unpkg.com"], + imgSrc: ["'self'", "data:", "https://*.tile.openstreetmap.org"], + connectSrc: ["'self'"] + } + } +})); + +// CORS configuration +app.use(cors({ + origin: function(origin, callback) { + // Allow requests with no origin (like mobile apps or curl requests) + if (!origin) return callback(null, true); + + const allowedOrigins = process.env.ALLOWED_ORIGINS?.split(',') || []; + if (allowedOrigins.includes(origin) || allowedOrigins.includes('*')) { + callback(null, true); + } else { + callback(new Error('Not allowed by CORS')); + } + }, + credentials: true, + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], + allowedHeaders: ['Content-Type', 'Authorization'] +})); + +// Trust proxy for Cloudflare +app.set('trust proxy', true); + +// Rate limiting with Cloudflare support +const limiter = rateLimit({ + windowMs: 15 * 60 * 1000, + max: 100, + keyGenerator: (req) => { + // Use CF-Connecting-IP header if available (Cloudflare) + return req.headers['cf-connecting-ip'] || + req.headers['x-forwarded-for']?.split(',')[0] || + req.ip; + }, + standardHeaders: true, + legacyHeaders: false, +}); + +const strictLimiter = rateLimit({ + windowMs: 15 * 60 * 1000, + max: 20, + keyGenerator: (req) => { + return req.headers['cf-connecting-ip'] || + req.headers['x-forwarded-for']?.split(',')[0] || + req.ip; + } +}); + +const authLimiter = rateLimit({ + windowMs: 15 * 60 * 1000, + max: process.env.NODE_ENV === 'production' ? 10 : 50, // Increase limit slightly + message: 'Too many login attempts, please try again later.', + keyGenerator: (req) => { + return req.headers['cf-connecting-ip'] || + req.headers['x-forwarded-for']?.split(',')[0] || + req.ip; + }, + standardHeaders: true, + legacyHeaders: false, +}); + +// Middleware +app.use(express.json({ limit: '10mb' })); + +// Authentication middleware +const requireAuth = (req, res, next) => { + if (req.session && req.session.authenticated) { + next(); + } else { + if (req.xhr || req.headers.accept?.indexOf('json') > -1) { + res.status(401).json({ success: false, error: 'Authentication required' }); + } else { + res.redirect('/login.html'); + } + } +}; + +// Serve login page without authentication +app.get('/login.html', (req, res) => { + res.sendFile(path.join(__dirname, 'public', 'login.html')); +}); + +// Auth routes (no authentication required) +app.post('/api/auth/login', authLimiter, async (req, res) => { + try { + // Log request details for debugging + logger.info('Login attempt:', { + email: req.body.email, + ip: req.ip, + cfIp: req.headers['cf-connecting-ip'], + forwardedFor: req.headers['x-forwarded-for'], + userAgent: req.headers['user-agent'] + }); + + const { email } = req.body; + + if (!email) { + return res.status(400).json({ + success: false, + error: 'Email is required' + }); + } + + // Validate email format + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + if (!emailRegex.test(email)) { + return res.status(400).json({ + success: false, + error: 'Invalid email format' + }); + } + + // Check if login sheet is configured + if (!LOGIN_SHEET_ID) { + logger.error('NOCODB_LOGIN_SHEET not configured or could not be parsed'); + return res.status(500).json({ + success: false, + error: 'Authentication system not properly configured' + }); + } + + // Fetch authorized emails from NocoDB + const url = `${process.env.NOCODB_API_URL}/db/data/v1/${process.env.NOCODB_PROJECT_ID}/${LOGIN_SHEET_ID}`; + + logger.info(`Checking authentication for email: ${email}`); + logger.debug(`Using login sheet API: ${url}`); + + const response = await axios.get(url, { + headers: { + 'xc-token': process.env.NOCODB_API_TOKEN, + 'Content-Type': 'application/json' + }, + params: { + limit: 1000 // Adjust if you have more authorized users + } + }); + + const users = response.data.list || []; + + // Check if email exists in the authorized users list + const authorizedUser = users.find(user => + user.Email && user.Email.toLowerCase() === email.toLowerCase() + ); + + if (authorizedUser) { + // Set session + req.session.authenticated = true; + req.session.userEmail = email; + req.session.userName = authorizedUser.Name || email; + + // Force session save before sending response + req.session.save((err) => { + if (err) { + logger.error('Session save error:', err); + return res.status(500).json({ + success: false, + error: 'Session error. Please try again.' + }); + } + + logger.info(`User authenticated: ${email}`); + + res.json({ + success: true, + message: 'Login successful', + user: { + email: email, + name: req.session.userName + } + }); + }); + } else { + logger.warn(`Authentication failed for email: ${email}`); + res.status(401).json({ + success: false, + error: 'Email not authorized. Please contact an administrator.' + }); + } + + } catch (error) { + logger.error('Login error:', error.message); + res.status(500).json({ + success: false, + error: 'Authentication service error. Please try again later.' + }); + } +}); + +app.get('/api/auth/check', (req, res) => { + res.json({ + authenticated: req.session?.authenticated || false, + user: req.session?.authenticated ? { + email: req.session.userEmail, + name: req.session.userName + } : null + }); +}); + +app.post('/api/auth/logout', (req, res) => { + req.session.destroy((err) => { + if (err) { + logger.error('Logout error:', err); + return res.status(500).json({ + success: false, + error: 'Logout failed' + }); + } + res.json({ + success: true, + message: 'Logged out successfully' + }); + }); +}); + +// Add this after the /api/auth/check route +app.get('/api/debug/session', (req, res) => { + res.json({ + sessionID: req.sessionID, + session: req.session, + cookies: req.cookies, + authenticated: req.session?.authenticated || false + }); +}); + +// Serve static files with authentication for main app +app.use(express.static(path.join(__dirname, 'public'), { + index: false // Don't serve index.html automatically +})); + +// Protect main app routes +app.get('/', requireAuth, (req, res) => { + res.sendFile(path.join(__dirname, 'public', 'index.html')); +}); + +// Add geocoding routes (protected) +app.use('/api/geocode', requireAuth, geocodingRoutes); + +// Apply rate limiting to API routes +app.use('/api/', limiter); + +// Health check endpoint (no auth required) +app.get('/health', (req, res) => { + res.json({ + status: 'healthy', + timestamp: new Date().toISOString(), + version: process.env.npm_package_version || '1.0.0' + }); +}); + +// Configuration validation endpoint (protected) +app.get('/api/config-check', requireAuth, (req, res) => { + const config = { + hasApiUrl: !!process.env.NOCODB_API_URL, + hasApiToken: !!process.env.NOCODB_API_TOKEN, + hasProjectId: !!process.env.NOCODB_PROJECT_ID, + hasTableId: !!process.env.NOCODB_TABLE_ID, + hasLoginSheet: !!LOGIN_SHEET_ID, + projectId: process.env.NOCODB_PROJECT_ID, + tableId: process.env.NOCODB_TABLE_ID, + loginSheet: LOGIN_SHEET_ID, + loginSheetConfigured: process.env.NOCODB_LOGIN_SHEET, + nodeEnv: process.env.NODE_ENV + }; + + const isConfigured = config.hasApiUrl && config.hasApiToken && config.hasProjectId && config.hasTableId; + + res.json({ + configured: isConfigured, + ...config + }); +}); + +// All other API routes require authentication +app.use('/api/*', requireAuth); + +// Get all locations from NocoDB +app.get('/api/locations', async (req, res) => { + try { + const { limit = 1000, offset = 0, where } = req.query; + + const url = `${process.env.NOCODB_API_URL}/db/data/v1/${process.env.NOCODB_PROJECT_ID}/${process.env.NOCODB_TABLE_ID}`; + + const params = new URLSearchParams({ + limit, + offset + }); + + if (where) { + params.append('where', where); + } + + logger.info(`Fetching locations from NocoDB: ${url}`); + + const response = await axios.get(`${url}?${params}`, { + headers: { + 'xc-token': process.env.NOCODB_API_TOKEN, + 'Content-Type': 'application/json' + }, + timeout: 10000 // 10 second timeout + }); + + // Process locations to ensure they have required fields + const locations = response.data.list || []; + + const validLocations = locations.filter(loc => { + // Apply geo field synchronization to each location + loc = syncGeoFields(loc); + + // Check if location has valid coordinates + if (loc.latitude && loc.longitude) { + return true; + } + + // Try to parse from geodata column (semicolon-separated) + if (loc.geodata && typeof loc.geodata === 'string') { + const parts = loc.geodata.split(';'); + if (parts.length === 2) { + loc.latitude = parseFloat(parts[0]); + loc.longitude = parseFloat(parts[1]); + return !isNaN(loc.latitude) && !isNaN(loc.longitude); + } + } + + // Try to parse from Geo-Location column (semicolon-separated first, then comma) + if (loc['Geo-Location'] && typeof loc['Geo-Location'] === 'string') { + // Try semicolon first (as we see in the data) + let parts = loc['Geo-Location'].split(';'); + if (parts.length === 2) { + loc.latitude = parseFloat(parts[0].trim()); + loc.longitude = parseFloat(parts[1].trim()); + if (!isNaN(loc.latitude) && !isNaN(loc.longitude)) { + return true; + } + } + + // Fallback to comma-separated + parts = loc['Geo-Location'].split(','); + if (parts.length === 2) { + loc.latitude = parseFloat(parts[0].trim()); + loc.longitude = parseFloat(parts[1].trim()); + return !isNaN(loc.latitude) && !isNaN(loc.longitude); + } + } + + return false; + }); + + logger.info(`Retrieved ${validLocations.length} valid locations out of ${locations.length} total`); + + res.json({ + success: true, + count: validLocations.length, + total: response.data.pageInfo?.totalRows || validLocations.length, + locations: validLocations + }); + + } catch (error) { + logger.error('Error fetching locations:', error.message); + + if (error.response) { + // NocoDB API error + res.status(error.response.status).json({ + success: false, + error: 'Failed to fetch data from NocoDB', + details: error.response.data + }); + } else if (error.code === 'ECONNABORTED') { + // Timeout + res.status(504).json({ + success: false, + error: 'Request timeout' + }); + } else { + // Other errors + res.status(500).json({ + success: false, + error: 'Internal server error' + }); + } + } +}); + +// Get single location by ID +app.get('/api/locations/:id', async (req, res) => { + try { + const url = `${process.env.NOCODB_API_URL}/db/data/v1/${process.env.NOCODB_PROJECT_ID}/${process.env.NOCODB_TABLE_ID}/${req.params.id}`; + + const response = await axios.get(url, { + headers: { + 'xc-token': process.env.NOCODB_API_TOKEN + } + }); + + res.json({ + success: true, + location: response.data + }); + + } catch (error) { + logger.error(`Error fetching location ${req.params.id}:`, error.message); + res.status(error.response?.status || 500).json({ + success: false, + error: 'Failed to fetch location' + }); + } +}); + +// Create new location +app.post('/api/locations', strictLimiter, async (req, res) => { + try { + let locationData = { ...req.body }; + + // Sync geo fields before validation + locationData = syncGeoFields(locationData); + + const { latitude, longitude, ...additionalData } = locationData; + + // Validate coordinates + if (!latitude || !longitude) { + return res.status(400).json({ + success: false, + error: 'Latitude and longitude are required' + }); + } + + const lat = parseFloat(latitude); + const lng = parseFloat(longitude); + + if (isNaN(lat) || isNaN(lng)) { + return res.status(400).json({ + success: false, + error: 'Invalid coordinate values' + }); + } + + if (lat < -90 || lat > 90) { + return res.status(400).json({ + success: false, + error: 'Latitude must be between -90 and 90' + }); + } + + if (lng < -180 || lng > 180) { + return res.status(400).json({ + success: false, + error: 'Longitude must be between -180 and 180' + }); + } + + // Check bounds if configured + if (process.env.BOUND_NORTH) { + const bounds = { + north: parseFloat(process.env.BOUND_NORTH), + south: parseFloat(process.env.BOUND_SOUTH), + east: parseFloat(process.env.BOUND_EAST), + west: parseFloat(process.env.BOUND_WEST) + }; + + if (lat > bounds.north || lat < bounds.south || + lng > bounds.east || lng < bounds.west) { + return res.status(400).json({ + success: false, + error: 'Location is outside allowed bounds' + }); + } + } + + // Format geodata in both formats for compatibility + const geodata = `${lat};${lng}`; + const geoLocation = `${lat};${lng}`; // Use semicolon format for NocoDB GeoData column + + // Prepare data for NocoDB + const finalData = { + geodata, + 'Geo-Location': geoLocation, + latitude: lat, + longitude: lng, + ...additionalData, + created_at: new Date().toISOString(), + created_by: req.session.userEmail // Track who created the location + }; + + const url = `${process.env.NOCODB_API_URL}/db/data/v1/${process.env.NOCODB_PROJECT_ID}/${process.env.NOCODB_TABLE_ID}`; + + logger.info('Creating new location:', { lat, lng }); + + const response = await axios.post(url, finalData, { + headers: { + 'xc-token': process.env.NOCODB_API_TOKEN, + 'Content-Type': 'application/json' + } + }); + + logger.info('Location created successfully:', response.data.id); + + res.status(201).json({ + success: true, + location: response.data + }); + + } catch (error) { + logger.error('Error creating location:', error.message); + + if (error.response) { + res.status(error.response.status).json({ + success: false, + error: 'Failed to save location to NocoDB', + details: error.response.data + }); + } else { + res.status(500).json({ + success: false, + error: 'Internal server error' + }); + } + } +}); + +// Update location +app.put('/api/locations/:id', strictLimiter, async (req, res) => { + try { + let updateData = { ...req.body }; + + // Sync geo fields + updateData = syncGeoFields(updateData); + + updateData.updated_at = new Date().toISOString(); + updateData.updated_by = req.session.userEmail; // Track who updated + + const url = `${process.env.NOCODB_API_URL}/db/data/v1/${process.env.NOCODB_PROJECT_ID}/${process.env.NOCODB_TABLE_ID}/${req.params.id}`; + + const response = await axios.patch(url, updateData, { + headers: { + 'xc-token': process.env.NOCODB_API_TOKEN, + 'Content-Type': 'application/json' + } + }); + + res.json({ + success: true, + location: response.data + }); + + } catch (error) { + logger.error(`Error updating location ${req.params.id}:`, error.message); + res.status(error.response?.status || 500).json({ + success: false, + error: 'Failed to update location' + }); + } +}); + +// Delete location +app.delete('/api/locations/:id', strictLimiter, async (req, res) => { + try { + const url = `${process.env.NOCODB_API_URL}/db/data/v1/${process.env.NOCODB_PROJECT_ID}/${process.env.NOCODB_TABLE_ID}/${req.params.id}`; + + await axios.delete(url, { + headers: { + 'xc-token': process.env.NOCODB_API_TOKEN + } + }); + + logger.info(`Location ${req.params.id} deleted by ${req.session.userEmail}`); + + res.json({ + success: true, + message: 'Location deleted successfully' + }); + + } catch (error) { + logger.error(`Error deleting location ${req.params.id}:`, error.message); + res.status(error.response?.status || 500).json({ + success: false, + error: 'Failed to delete location' + }); + } +}); + +// Error handling middleware +app.use((err, req, res, next) => { + logger.error('Unhandled error:', err); + res.status(500).json({ + success: false, + error: 'Internal server error' + }); +}); + +// Start server +app.listen(PORT, () => { + logger.info(` + ╔════════════════════════════════════════╗ + ║ NocoDB Map Viewer Server ║ + ╠════════════════════════════════════════╣ + ║ Status: Running ║ + ║ Port: ${PORT} ║ + ║ Environment: ${process.env.NODE_ENV || 'development'} ║ + ║ Project ID: ${process.env.NOCODB_PROJECT_ID} ║ + ║ Table ID: ${process.env.NOCODB_TABLE_ID} ║ + ║ Login Sheet: ${LOGIN_SHEET_ID || 'Not Configured'} ║ + ║ Time: ${new Date().toISOString()} ║ + ╚════════════════════════════════════════╝ + `); +}); + +// Graceful shutdown +process.on('SIGTERM', () => { + logger.info('SIGTERM signal received: closing HTTP server'); + app.close(() => { + logger.info('HTTP server closed'); + process.exit(0); + }); +}); + diff --git a/map/app/services/geocoding.js b/map/app/services/geocoding.js new file mode 100644 index 0000000..d26a6f1 --- /dev/null +++ b/map/app/services/geocoding.js @@ -0,0 +1,231 @@ +const axios = require('axios'); +const winston = require('winston'); + +// Configure logger +const logger = winston.createLogger({ + level: process.env.NODE_ENV === 'production' ? 'info' : 'debug', + format: winston.format.combine( + winston.format.timestamp(), + winston.format.json() + ), + transports: [ + new winston.transports.Console({ + format: winston.format.simple() + }) + ] +}); + +// Cache for geocoding results (simple in-memory cache) +const geocodeCache = new Map(); +const CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours + +// Clean up old cache entries periodically +setInterval(() => { + const now = Date.now(); + for (const [key, value] of geocodeCache.entries()) { + if (now - value.timestamp > CACHE_TTL) { + geocodeCache.delete(key); + } + } +}, 60 * 60 * 1000); // Run every hour + +/** + * Reverse geocode coordinates to get address + * @param {number} lat - Latitude + * @param {number} lng - Longitude + * @returns {Promise} Geocoding result + */ +async function reverseGeocode(lat, lng) { + // Create cache key + const cacheKey = `${lat.toFixed(6)},${lng.toFixed(6)}`; + + // Check cache first + const cached = geocodeCache.get(cacheKey); + if (cached && Date.now() - cached.timestamp < CACHE_TTL) { + logger.debug(`Geocoding cache hit for ${cacheKey}`); + return cached.data; + } + + try { + // Add delay to respect Nominatim rate limits (max 1 request per second) + await new Promise(resolve => setTimeout(resolve, 1000)); + + logger.info(`Reverse geocoding: ${lat}, ${lng}`); + + const response = await axios.get('https://nominatim.openstreetmap.org/reverse', { + params: { + format: 'json', + lat: lat, + lon: lng, + zoom: 18, + addressdetails: 1, + 'accept-language': 'en' + }, + headers: { + 'User-Agent': 'NocoDB Map Viewer 1.0 (https://github.com/yourusername/nocodb-map-viewer)' + }, + timeout: 10000 + }); + + if (response.data.error) { + throw new Error(response.data.error); + } + + // Process the response + const result = processGeocodeResponse(response.data); + + // Cache the result + geocodeCache.set(cacheKey, { + data: result, + timestamp: Date.now() + }); + + return result; + + } catch (error) { + logger.error('Reverse geocoding error:', error.message); + + if (error.response?.status === 429) { + throw new Error('Rate limit exceeded. Please try again later.'); + } else if (error.code === 'ECONNABORTED') { + throw new Error('Geocoding service timeout'); + } else { + throw new Error('Geocoding service unavailable'); + } + } +} + +/** + * Forward geocode address to get coordinates + * @param {string} address - Address to geocode + * @returns {Promise} Geocoding result + */ +async function forwardGeocode(address) { + // Create cache key + const cacheKey = `addr:${address.toLowerCase()}`; + + // Check cache first + const cached = geocodeCache.get(cacheKey); + if (cached && Date.now() - cached.timestamp < CACHE_TTL) { + logger.debug(`Geocoding cache hit for ${cacheKey}`); + return cached.data; + } + + try { + // Add delay to respect rate limits + await new Promise(resolve => setTimeout(resolve, 1000)); + + logger.info(`Forward geocoding: ${address}`); + + const response = await axios.get('https://nominatim.openstreetmap.org/search', { + params: { + format: 'json', + q: address, + limit: 1, + addressdetails: 1, + 'accept-language': 'en' + }, + headers: { + 'User-Agent': 'NocoDB Map Viewer 1.0 (https://github.com/yourusername/nocodb-map-viewer)' + }, + timeout: 10000 + }); + + if (!response.data || response.data.length === 0) { + throw new Error('No results found'); + } + + // Process the first result + const result = processGeocodeResponse(response.data[0]); + + // Cache the result + geocodeCache.set(cacheKey, { + data: result, + timestamp: Date.now() + }); + + return result; + + } catch (error) { + logger.error('Forward geocoding error:', error.message); + + if (error.response?.status === 429) { + throw new Error('Rate limit exceeded. Please try again later.'); + } else if (error.code === 'ECONNABORTED') { + throw new Error('Geocoding service timeout'); + } else { + throw new Error('Geocoding service unavailable'); + } + } +} + +/** + * Process geocoding response into standardized format + * @param {Object} data - Raw geocoding response + * @returns {Object} Processed geocoding data + */ +function processGeocodeResponse(data) { + // Extract address components + const addressComponents = { + house_number: data.address?.house_number || '', + road: data.address?.road || '', + suburb: data.address?.suburb || data.address?.neighbourhood || '', + city: data.address?.city || data.address?.town || data.address?.village || '', + state: data.address?.state || data.address?.province || '', + postcode: data.address?.postcode || '', + country: data.address?.country || '' + }; + + // Create formatted address string + let formattedAddress = ''; + if (addressComponents.house_number) formattedAddress += addressComponents.house_number + ' '; + if (addressComponents.road) formattedAddress += addressComponents.road + ', '; + if (addressComponents.suburb) formattedAddress += addressComponents.suburb + ', '; + if (addressComponents.city) formattedAddress += addressComponents.city + ', '; + if (addressComponents.state) formattedAddress += addressComponents.state + ' '; + if (addressComponents.postcode) formattedAddress += addressComponents.postcode; + + // Clean up formatting + formattedAddress = formattedAddress.trim().replace(/,$/, ''); + + return { + fullAddress: data.display_name || '', + formattedAddress: formattedAddress, + components: addressComponents, + coordinates: { + lat: parseFloat(data.lat), + lng: parseFloat(data.lon) + }, + boundingBox: data.boundingbox || null, + placeId: data.place_id || null, + osmType: data.osm_type || null, + osmId: data.osm_id || null + }; +} + +/** + * Get cache statistics + * @returns {Object} Cache statistics + */ +function getCacheStats() { + return { + size: geocodeCache.size, + maxSize: 1000, // Could be made configurable + ttl: CACHE_TTL + }; +} + +/** + * Clear the geocoding cache + */ +function clearCache() { + geocodeCache.clear(); + logger.info('Geocoding cache cleared'); +} + +module.exports = { + reverseGeocode, + forwardGeocode, + getCacheStats, + clearCache +}; diff --git a/map/docker-compose.yml b/map/docker-compose.yml new file mode 100644 index 0000000..ff49eba --- /dev/null +++ b/map/docker-compose.yml @@ -0,0 +1,27 @@ +version: '3.8' + +services: + map-viewer: + build: + context: ./app + dockerfile: Dockerfile + container_name: nocodb-map-viewer + ports: + - "${PORT:-3000}:3000" + environment: + - NODE_ENV=${NODE_ENV:-production} + - PORT=${PORT:-3000} + env_file: + - .env + restart: unless-stopped + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" diff --git a/mkdocs/docs/cloudflare/index.md b/mkdocs/docs/cloudflare/index.md new file mode 100644 index 0000000..3601fdf --- /dev/null +++ b/mkdocs/docs/cloudflare/index.md @@ -0,0 +1,7 @@ +# Cloudflare + +In this section, you will find instructions on how to properly set up Cloudflare for managing a Changemaker-lite. + +## Config + +When you first run the `./config.sh` it will prompt you for the a api token, zone id, and a tunnel id. A \ No newline at end of file diff --git a/mkdocs/docs/overrides/main.html b/mkdocs/docs/overrides/main.html index 732197a..8e9cee7 100644 --- a/mkdocs/docs/overrides/main.html +++ b/mkdocs/docs/overrides/main.html @@ -4,6 +4,6 @@ {% endblock %} {% block announce %} - + Changemaker Archive. Learn more {% endblock %} diff --git a/mkdocs/docs/overrides/main.html.backup_20250602_184336 b/mkdocs/docs/overrides/main.html.backup_20250629_154241 similarity index 100% rename from mkdocs/docs/overrides/main.html.backup_20250602_184336 rename to mkdocs/docs/overrides/main.html.backup_20250629_154241 diff --git a/mkdocs/docs/overrides/main.html.backup_20250629_154929 b/mkdocs/docs/overrides/main.html.backup_20250629_154929 new file mode 100644 index 0000000..732197a --- /dev/null +++ b/mkdocs/docs/overrides/main.html.backup_20250629_154929 @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block extrahead %} +{% endblock %} + +{% block announce %} + +Changemaker Archive. Learn more +{% endblock %} diff --git a/mkdocs/mkdocs.yml b/mkdocs/mkdocs.yml index 5c2ec6c..ba42217 100644 --- a/mkdocs/mkdocs.yml +++ b/mkdocs/mkdocs.yml @@ -1,6 +1,6 @@ site_name: Changemaker Lite Documentation site_description: Self-hosted platform for documentation and development -site_url: https://changeme.org +site_url: https://cmlite.org site_author: Bunker Ops docs_dir: docs site_dir: site diff --git a/mkdocs/mkdocs.yml.backup_20250629_154929 b/mkdocs/mkdocs.yml.backup_20250629_154929 new file mode 100644 index 0000000..5c2ec6c --- /dev/null +++ b/mkdocs/mkdocs.yml.backup_20250629_154929 @@ -0,0 +1,66 @@ +site_name: Changemaker Lite Documentation +site_description: Self-hosted platform for documentation and development +site_url: https://changeme.org +site_author: Bunker Ops +docs_dir: docs +site_dir: site + +# Theme +theme: + name: material + custom_dir: docs/overrides + palette: + scheme: slate + primary: deep purple + accent: amber + features: + - navigation.tracking + - navigation.indexes + - navigation.collapse + - navigation.path + - content.code.copy + - navigation.top + - navigation.tabs # Added for top-level navigation tabs + +extra_css: + - stylesheets/extra.css +markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.superfences + - admonition + - pymdownx.details + - attr_list + - md_in_html + - pymdownx.emoji # Simplified emoji config + - footnotes + - toc: + permalink: true + # The specific slugify line was removed to avoid previous tool error, + # you may need to add back your preferred slugify option: + # slugify: !!python/name:pymdownx.slugs.uslugify + +copyright: Copyright © 2024 The Bunker Operations - Built with Change Maker + +# Plugins +plugins: + - social + - search + - blog + # - tags # Consider adding if you use tags for your blog or docs + +# Navigation +nav: + - Home: index.md + - Getting Started: getting-started.md + - Services: + - Overview: services/index.md + - Homepage: services/homepage.md + - Code Server: services/code-server.md + - MkDocs Material: services/mkdocs.md + - Static Site Server: services/static-server.md + - Listmonk: services/listmonk.md + - PostgreSQL: services/postgresql.md + - n8n: services/n8n.md + - NocoDB: services/nocodb.md + - Blog: blog/index.md diff --git a/start-production.sh b/start-production.sh new file mode 100644 index 0000000..02e1361 --- /dev/null +++ b/start-production.sh @@ -0,0 +1,348 @@ +#!/bin/bash + +echo "#############################################################" +echo "# " +echo "# Changemaker.lite Production Setup " +echo "# " +echo "# This script will: " +echo "# 1. Create a Cloudflare tunnel " +echo "# 2. Configure DNS records " +echo "# 3. Set up access policies " +echo "# 4. Enable the cloudflared container " +echo "# " +echo "#############################################################" +echo "" + +# Get script directory +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ENV_FILE="$SCRIPT_DIR/.env" +DOCKER_COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml" + +# Source environment variables +if [ -f "$ENV_FILE" ]; then + export $(grep -v '^#' "$ENV_FILE" | xargs) +else + echo "Error: .env file not found. Please run ./config.sh first." + exit 1 +fi + +# Check if Cloudflare credentials are properly configured +if [ -z "$CF_API_TOKEN" ] || [ "$CF_API_TOKEN" == "your_cloudflare_api_token" ] || \ + [ -z "$CF_ZONE_ID" ] || [ "$CF_ZONE_ID" == "your_cloudflare_zone_id" ] || \ + [ -z "$CF_DOMAIN" ]; then + echo "Error: Cloudflare credentials not properly configured in .env file." + echo "" + echo "Current values:" + echo " CF_API_TOKEN: ${CF_API_TOKEN:-not set}" + echo " CF_ZONE_ID: ${CF_ZONE_ID:-not set}" + echo " CF_DOMAIN: ${CF_DOMAIN:-not set}" + echo "" + echo "Please run ./config.sh and configure Cloudflare settings, or manually update your .env file." + exit 1 +fi + +# Check if CF_ACCOUNT_ID exists in .env, if not prompt for it +if [ -z "$CF_ACCOUNT_ID" ]; then + echo "Cloudflare Account ID is required for tunnel creation." + echo "You can find it in your Cloudflare dashboard at the top right." + read -p "Enter your Cloudflare Account ID: " CF_ACCOUNT_ID + + # Update .env with account ID + echo "" >> "$ENV_FILE" + echo "# Cloudflare Account ID (added by start-production.sh)" >> "$ENV_FILE" + echo "CF_ACCOUNT_ID=$CF_ACCOUNT_ID" >> "$ENV_FILE" + + # Re-export the variable + export CF_ACCOUNT_ID +fi + +# Check if required variables are set +if [ -z "$CF_API_TOKEN" ] || [ -z "$CF_ZONE_ID" ] || [ -z "$CF_DOMAIN" ]; then + echo "Error: Cloudflare credentials not found in .env file." + echo "Please run ./config.sh and configure Cloudflare settings." + exit 1 +fi + +# Check if services are running +echo "Checking if services are running..." +if ! docker compose ps | grep -q "Up"; then + echo "Error: No services are running. Please run 'docker compose up -d' first." + exit 1 +fi + +echo "✓ Services are running" +echo "" + +# Show current service URLs +echo "Current local service URLs:" +echo " - Homepage: http://localhost:${HOMEPAGE_PORT:-3010}" +echo " - Code Server: http://localhost:${CODE_SERVER_PORT:-8888}" +echo " - Listmonk: http://localhost:${LISTMONK_PORT:-9000}" +echo " - Documentation (Dev): http://localhost:${MKDOCS_PORT:-4000}" +echo " - Documentation (Built): http://localhost:${MKDOCS_SITE_SERVER_PORT:-4001}" +echo " - n8n: http://localhost:${N8N_PORT:-5678}" +echo " - NocoDB: http://localhost:${NOCODB_PORT:-8090}" +echo " - Gitea: http://localhost:${GITEA_WEB_PORT:-3030}" +echo "" + +read -p "Have you tested all services locally and are ready to go to production? (yes/no): " confirm +if [[ "$confirm" != "yes" ]]; then + echo "Please test all services locally before running production setup." + exit 0 +fi + +echo "" +echo "Starting production setup..." + +# Install jq if not present +if ! command -v jq &> /dev/null; then + echo "Installing jq..." + sudo apt-get update && sudo apt-get install -y jq +fi + +# Create Cloudflare tunnel +echo "" +echo "Creating Cloudflare tunnel..." + +TUNNEL_NAME="changemaker-${HOSTNAME}-$(date +%s)" + +# Create tunnel via API +TUNNEL_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/cfd_tunnel" \ + -H "Authorization: Bearer $CF_API_TOKEN" \ + -H "Content-Type: application/json" \ + --data "{\"name\":\"$TUNNEL_NAME\",\"config_src\":\"cloudflare\"}") + +# Check if we need account ID +if echo "$TUNNEL_RESPONSE" | jq -e '.errors[] | select(.code == 0)' > /dev/null 2>&1; then + echo "" + echo "Account ID is required. You can find it in your Cloudflare dashboard." + read -p "Enter your Cloudflare Account ID: " CF_ACCOUNT_ID + + # Update .env with account ID + if grep -q "^CF_ACCOUNT_ID=" "$ENV_FILE"; then + sed -i "s/^CF_ACCOUNT_ID=.*/CF_ACCOUNT_ID=$CF_ACCOUNT_ID/" "$ENV_FILE" + else + echo "CF_ACCOUNT_ID=$CF_ACCOUNT_ID" >> "$ENV_FILE" + fi + + # Retry with account ID + TUNNEL_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/cfd_tunnel" \ + -H "Authorization: Bearer $CF_API_TOKEN" \ + -H "Content-Type: application/json" \ + --data "{\"name\":\"$TUNNEL_NAME\",\"config_src\":\"cloudflare\"}") +fi + +TUNNEL_ID=$(echo "$TUNNEL_RESPONSE" | jq -r '.result.id') +TUNNEL_TOKEN=$(echo "$TUNNEL_RESPONSE" | jq -r '.result.token') + +if [ -z "$TUNNEL_ID" ] || [ "$TUNNEL_ID" == "null" ]; then + echo "Error: Failed to create tunnel" + echo "$TUNNEL_RESPONSE" | jq . + exit 1 +fi + +echo "✓ Created tunnel: $TUNNEL_NAME (ID: $TUNNEL_ID)" + +# Update .env with tunnel information +echo "CF_TUNNEL_ID=$TUNNEL_ID" >> "$ENV_FILE" +echo "CF_TUNNEL_TOKEN=$TUNNEL_TOKEN" >> "$ENV_FILE" +echo "CF_TUNNEL_NAME=$TUNNEL_NAME" >> "$ENV_FILE" + +# Configure tunnel routes +echo "" +echo "Configuring tunnel routes..." + +# Define services and their configurations +declare -A SERVICES=( + ["dashboard"]="homepage-changemaker:3000" + ["code"]="code-server:8080" + ["listmonk"]="listmonk-app:9000" + ["docs"]="mkdocs:8000" + ["n8n"]="n8n:5678" + ["db"]="nocodb:8080" + ["git"]="gitea-app:3000" +) + +# Configure root domain to mkdocs-site-server +echo "Configuring route for root domain..." +ROOT_CONFIG=$(cat < $service" + + CONFIG=$(cat < /dev/null; then + echo "✓ DNS record for $name.$CF_DOMAIN configured" + else + echo "✗ Failed to configure DNS record for $name.$CF_DOMAIN" + echo "$RESPONSE" | jq '.errors' + fi +} + +# Create DNS records for all subdomains +for subdomain in "${!SERVICES[@]}"; do + create_dns_record "$subdomain" +done + +# Create root domain record +create_dns_record "@" + +# Set up access policies +echo "" +echo "Setting up access policies..." +read -p "Enter admin email for protected services (dashboard, code): " ADMIN_EMAIL + +if [[ "$ADMIN_EMAIL" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then + # Create access applications for protected services + PROTECTED_SERVICES=("dashboard" "code") + + for service in "${PROTECTED_SERVICES[@]}"; do + echo "Creating access policy for $service.$CF_DOMAIN..." + + # Create access application + APP_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/access/apps" \ + -H "Authorization: Bearer $CF_API_TOKEN" \ + -H "Content-Type: application/json" \ + --data "{ + \"name\": \"$service.$CF_DOMAIN\", + \"domain\": \"$service.$CF_DOMAIN\", + \"type\": \"self_hosted\", + \"session_duration\": \"24h\" + }") + + APP_ID=$(echo "$APP_RESPONSE" | jq -r '.result.id') + + if [ ! -z "$APP_ID" ] && [ "$APP_ID" != "null" ]; then + # Create policy + POLICY_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/access/apps/$APP_ID/policies" \ + -H "Authorization: Bearer $CF_API_TOKEN" \ + -H "Content-Type: application/json" \ + --data "{ + \"name\": \"Email Policy\", + \"decision\": \"allow\", + \"include\": [{ + \"email\": {\"email\": \"$ADMIN_EMAIL\"} + }] + }") + + echo "✓ Access policy created for $service.$CF_DOMAIN" + fi + done +else + echo "Invalid email format. Skipping access policy setup." +fi + +# Enable cloudflared in docker-compose +echo "" +echo "Enabling cloudflared container..." + +# Uncomment cloudflared service in docker-compose.yml +sed -i '/# cloudflared:/,/# gitea-app/s/^ # / /' "$DOCKER_COMPOSE_FILE" + +# Start cloudflared container +docker compose up -d cloudflared + +echo "" +echo "#############################################################" +echo "# " +echo "# Production Setup Complete! " +echo "# " +echo "#############################################################" +echo "" +echo "Your services are now accessible at:" +echo "" +echo "Public services:" +echo " - Main Site: https://$CF_DOMAIN" +echo " - Listmonk: https://listmonk.$CF_DOMAIN" +echo " - Documentation: https://docs.$CF_DOMAIN" +echo " - n8n: https://n8n.$CF_DOMAIN" +echo " - NocoDB: https://db.$CF_DOMAIN" +echo " - Gitea: https://git.$CF_DOMAIN" +echo "" +if [ ! -z "$ADMIN_EMAIL" ]; then + echo "Protected services (login required with $ADMIN_EMAIL):" + echo " - Dashboard: https://dashboard.$CF_DOMAIN" + echo " - Code Server: https://code.$CF_DOMAIN" +else + echo "Admin services (no protection configured):" + echo " - Dashboard: https://dashboard.$CF_DOMAIN" + echo " - Code Server: https://code.$CF_DOMAIN" +fi +echo "" +echo "Note: DNS propagation may take a few minutes." +echo "" +echo "To stop production mode and return to local-only:" +echo " docker compose stop cloudflared" +echo "" +echo "To fully remove production setup:" +echo " docker compose down cloudflared" \ No newline at end of file