#!/bin/bash
# Test script to debug backend-api configuration loading

set -a
source /etc/veza/backend-api.env
set +a

echo "=== Environment Variables ===" >&2
echo "APP_ENV=$APP_ENV" >&2
echo "DATABASE_URL=${DATABASE_URL:0:50}..." >&2
echo "JWT_SECRET length: ${#JWT_SECRET}" >&2
echo "CORS_ALLOWED_ORIGINS=$CORS_ALLOWED_ORIGINS" >&2
echo "" >&2

echo "=== Testing binary execution ===" >&2
cd /opt/veza/backend-api
/usr/local/bin/veza-backend-api 2>&1 | head -20 || {
    EXIT_CODE=$?
    echo "Application exited with code: $EXIT_CODE" >&2
    exit $EXIT_CODE
}
