first commit

This commit is contained in:
Tomáš Dvořák
2025-10-02 12:39:28 +02:00
commit 0fc92f8464
60 changed files with 11834 additions and 0 deletions
+117
View File
@@ -0,0 +1,117 @@
# 🛠️ Utility Scripts
Helpful PowerShell scripts for managing the Czech Clubs Logos API.
## Available Scripts
### setup-check.ps1
Verifies your development environment is properly configured.
**Usage:**
```powershell
.\scripts\setup-check.ps1
```
**Checks:**
- Docker installation
- Docker Compose installation
- Go installation (optional)
- Node.js installation (optional)
- Project structure
- Port availability
### health-check.ps1
Tests if the services are running and responding correctly.
**Usage:**
```powershell
.\scripts\health-check.ps1
```
**Checks:**
- Backend health endpoint
- Frontend accessibility
- API functionality
**Note:** Services must be running first (`docker-compose up` or manual start)
### test-api.ps1
Comprehensive API endpoint testing suite.
**Usage:**
```powershell
# Test against localhost
.\scripts\test-api.ps1
# Test against custom URL
.\scripts\test-api.ps1 -BaseUrl "http://your-server:8080"
```
**Tests:**
- Health check endpoint
- Club search functionality
- Club details retrieval
- Logo metadata access
- Error handling (invalid UUIDs)
## Quick Reference
```powershell
# 1. Verify setup
.\scripts\setup-check.ps1
# 2. Start services
docker-compose up -d
# 3. Check health
.\scripts\health-check.ps1
# 4. Run API tests
.\scripts\test-api.ps1
```
## Script Permissions
If you get execution policy errors, run:
```powershell
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
```
## CI/CD Integration
These scripts can be integrated into CI/CD pipelines:
```yaml
# GitHub Actions example
- name: Verify Setup
run: pwsh ./scripts/setup-check.ps1
- name: Health Check
run: pwsh ./scripts/health-check.ps1
- name: Run API Tests
run: pwsh ./scripts/test-api.ps1
```
## Adding New Scripts
When adding new scripts:
1. Use `.ps1` extension
2. Add parameter support
3. Include help comments
4. Use colored output
5. Return proper exit codes
6. Update this README
## Tips
- Run scripts from project root directory
- Check script output colors:
- 🟢 Green = Success
- 🔴 Red = Error
- 🟡 Yellow = Warning
- ⚪ Gray = Info
---
**Need help?** Check the main [README.md](../README.md)
+52
View File
@@ -0,0 +1,52 @@
# Health Check Script for Czech Clubs Logos API
Write-Host "🏥 Czech Clubs Logos API - Health Check" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
# Backend Health Check
Write-Host "Checking Backend..." -ForegroundColor Yellow
try {
$backendResponse = Invoke-RestMethod -Uri "http://localhost:8080/health" -Method Get -TimeoutSec 5
Write-Host "✓ Backend is running" -ForegroundColor Green
Write-Host " Status: $($backendResponse.status)" -ForegroundColor Gray
} catch {
Write-Host "✗ Backend is not responding" -ForegroundColor Red
Write-Host " Make sure the backend is running on port 8080" -ForegroundColor Gray
}
Write-Host ""
# Frontend Health Check
Write-Host "Checking Frontend..." -ForegroundColor Yellow
try {
$frontendResponse = Invoke-WebRequest -Uri "http://localhost:3000" -Method Get -TimeoutSec 5
if ($frontendResponse.StatusCode -eq 200) {
Write-Host "✓ Frontend is running" -ForegroundColor Green
Write-Host " Status Code: $($frontendResponse.StatusCode)" -ForegroundColor Gray
}
} catch {
Write-Host "✗ Frontend is not responding" -ForegroundColor Red
Write-Host " Make sure the frontend is running on port 3000" -ForegroundColor Gray
}
Write-Host ""
# Test API Endpoint
Write-Host "Testing API Endpoints..." -ForegroundColor Yellow
try {
$searchResponse = Invoke-RestMethod -Uri "http://localhost:8080/clubs/search?q=sparta" -Method Get -TimeoutSec 5
$clubCount = $searchResponse.Count
Write-Host "✓ API search endpoint working" -ForegroundColor Green
Write-Host " Found $clubCount clubs" -ForegroundColor Gray
} catch {
Write-Host "✗ API search endpoint failed" -ForegroundColor Red
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Health check complete!" -ForegroundColor Cyan
Write-Host ""
Write-Host "URLs:" -ForegroundColor White
Write-Host " Frontend: http://localhost:3000" -ForegroundColor Cyan
Write-Host " Backend: http://localhost:8080" -ForegroundColor Cyan
Write-Host " Health: http://localhost:8080/health" -ForegroundColor Cyan
+110
View File
@@ -0,0 +1,110 @@
# Setup Verification Script for Czech Clubs Logos API
Write-Host "🔍 Czech Clubs Logos API - Setup Verification" -ForegroundColor Cyan
Write-Host "=============================================`n" -ForegroundColor Cyan
$allGood = $true
# Check Docker
Write-Host "Checking Docker..." -ForegroundColor Yellow
if (Get-Command docker -ErrorAction SilentlyContinue) {
$dockerVersion = docker --version
Write-Host "✓ Docker installed: $dockerVersion" -ForegroundColor Green
} else {
Write-Host "✗ Docker not found" -ForegroundColor Red
Write-Host " Install from: https://www.docker.com/products/docker-desktop" -ForegroundColor Gray
$allGood = $false
}
Write-Host ""
# Check Docker Compose
Write-Host "Checking Docker Compose..." -ForegroundColor Yellow
if (Get-Command docker-compose -ErrorAction SilentlyContinue) {
$composeVersion = docker-compose --version
Write-Host "✓ Docker Compose installed: $composeVersion" -ForegroundColor Green
} else {
Write-Host "✗ Docker Compose not found" -ForegroundColor Red
$allGood = $false
}
Write-Host ""
# Check Go (optional)
Write-Host "Checking Go (optional for local dev)..." -ForegroundColor Yellow
if (Get-Command go -ErrorAction SilentlyContinue) {
$goVersion = go version
Write-Host "✓ Go installed: $goVersion" -ForegroundColor Green
} else {
Write-Host "⚠ Go not found (optional)" -ForegroundColor DarkYellow
Write-Host " Install from: https://go.dev/dl/" -ForegroundColor Gray
}
Write-Host ""
# Check Node.js (optional)
Write-Host "Checking Node.js (optional for local dev)..." -ForegroundColor Yellow
if (Get-Command node -ErrorAction SilentlyContinue) {
$nodeVersion = node --version
Write-Host "✓ Node.js installed: $nodeVersion" -ForegroundColor Green
} else {
Write-Host "⚠ Node.js not found (optional)" -ForegroundColor DarkYellow
Write-Host " Install from: https://nodejs.org/" -ForegroundColor Gray
}
Write-Host ""
# Check project structure
Write-Host "Checking project structure..." -ForegroundColor Yellow
$requiredDirs = @("backend", "frontend")
$requiredFiles = @("docker-compose.yml", "README.md")
$structureGood = $true
foreach ($dir in $requiredDirs) {
if (Test-Path $dir) {
Write-Host "✓ Directory exists: $dir" -ForegroundColor Green
} else {
Write-Host "✗ Missing directory: $dir" -ForegroundColor Red
$structureGood = $false
}
}
foreach ($file in $requiredFiles) {
if (Test-Path $file) {
Write-Host "✓ File exists: $file" -ForegroundColor Green
} else {
Write-Host "✗ Missing file: $file" -ForegroundColor Red
$structureGood = $false
}
}
Write-Host ""
# Check ports
Write-Host "Checking if ports are available..." -ForegroundColor Yellow
$ports = @(3000, 8080)
foreach ($port in $ports) {
$connections = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
if ($connections) {
Write-Host "⚠ Port $port is in use" -ForegroundColor DarkYellow
Write-Host " You may need to stop the service using this port" -ForegroundColor Gray
} else {
Write-Host "✓ Port $port is available" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "=============================================" -ForegroundColor Cyan
if ($allGood -and $structureGood) {
Write-Host "✓ All checks passed! You're ready to start." -ForegroundColor Green
Write-Host ""
Write-Host "Run: docker-compose up" -ForegroundColor Cyan
} else {
Write-Host "⚠ Some issues found. Please resolve them before starting." -ForegroundColor Yellow
Write-Host ""
Write-Host "With Docker: docker-compose up" -ForegroundColor Cyan
Write-Host "Without Docker: See QUICKSTART.md for manual setup" -ForegroundColor Cyan
}
Write-Host ""
+100
View File
@@ -0,0 +1,100 @@
# API Testing Script for Czech Clubs Logos API
param(
[string]$BaseUrl = "http://localhost:8080"
)
Write-Host "🧪 Czech Clubs Logos API - Testing Suite" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
Write-Host "Testing against: $BaseUrl`n" -ForegroundColor Gray
$testsPassed = 0
$testsFailed = 0
function Test-Endpoint {
param(
[string]$Name,
[string]$Url,
[string]$Method = "GET"
)
Write-Host "Testing: $Name" -ForegroundColor Yellow
try {
$response = Invoke-RestMethod -Uri $Url -Method $Method -TimeoutSec 10
Write-Host " ✓ PASS" -ForegroundColor Green
$script:testsPassed++
return $response
} catch {
Write-Host " ✗ FAIL: $($_.Exception.Message)" -ForegroundColor Red
$script:testsFailed++
return $null
}
}
# Test 1: Health Check
Write-Host "1. Health Check" -ForegroundColor Cyan
$health = Test-Endpoint -Name "GET /health" -Url "$BaseUrl/health"
if ($health) {
Write-Host " Response: $($health | ConvertTo-Json -Compress)" -ForegroundColor Gray
}
Write-Host ""
# Test 2: Search Clubs
Write-Host "2. Club Search" -ForegroundColor Cyan
$searchResult = Test-Endpoint -Name "GET /clubs/search?q=sparta" -Url "$BaseUrl/clubs/search?q=sparta"
if ($searchResult) {
Write-Host " Found: $($searchResult.Count) clubs" -ForegroundColor Gray
if ($searchResult.Count -gt 0) {
Write-Host " First club: $($searchResult[0].name)" -ForegroundColor Gray
}
}
Write-Host ""
# Test 3: Search Different Query
Write-Host "3. Club Search (Slavia)" -ForegroundColor Cyan
$slaviaResult = Test-Endpoint -Name "GET /clubs/search?q=slavia" -Url "$BaseUrl/clubs/search?q=slavia"
if ($slaviaResult) {
Write-Host " Found: $($slaviaResult.Count) clubs" -ForegroundColor Gray
}
Write-Host ""
# Test 4: Get Club by ID (using demo UUID)
Write-Host "4. Get Club Details" -ForegroundColor Cyan
$demoUuid = "22222222-3333-4444-5555-666666666666"
Test-Endpoint -Name "GET /clubs/$demoUuid" -Url "$BaseUrl/clubs/$demoUuid" | Out-Null
Write-Host ""
# Test 5: Logo Metadata (may fail if no logo uploaded)
Write-Host "5. Logo Metadata (may fail if no logos uploaded)" -ForegroundColor Cyan
Test-Endpoint -Name "GET /logos/$demoUuid/json" -Url "$BaseUrl/logos/$demoUuid/json" | Out-Null
Write-Host ""
# Test 6: Invalid UUID (should fail gracefully)
Write-Host "6. Invalid UUID Test (expected to fail)" -ForegroundColor Cyan
Write-Host "Testing: GET /clubs/invalid-uuid" -ForegroundColor Yellow
try {
Invoke-RestMethod -Uri "$BaseUrl/clubs/invalid-uuid" -Method GET -TimeoutSec 5
Write-Host " ✗ Should have failed but didn't" -ForegroundColor Red
$testsFailed++
} catch {
Write-Host " ✓ Correctly rejected invalid UUID" -ForegroundColor Green
$testsPassed++
}
Write-Host ""
# Summary
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Test Results:" -ForegroundColor White
Write-Host " Passed: $testsPassed" -ForegroundColor Green
Write-Host " Failed: $testsFailed" -ForegroundColor $(if ($testsFailed -eq 0) { "Green" } else { "Red" })
Write-Host ""
if ($testsFailed -eq 0) {
Write-Host "✓ All tests passed! API is working correctly." -ForegroundColor Green
} else {
Write-Host "⚠ Some tests failed. Check the API server." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "Note: Logo upload tests require manual testing with files." -ForegroundColor Gray
Write-Host "Use the frontend or curl for upload testing." -ForegroundColor Gray