Skip to content

Commit a3f5946

Browse files
authored
feat: add test server (#26)
* feat: add server * feat: re-architecture of the server * fix: remove binary * feat: added log collector * fix: remove unused middleware * feat: add cloudrun DockerFile
1 parent fcf77ed commit a3f5946

30 files changed

+3428
-49
lines changed

.dockerignore

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Documentation
7+
README.md
8+
LICENSE.md
9+
SECURITY.md
10+
SERVER.md
11+
USERS.md
12+
CODE_OF_CONDUCT.md
13+
CONTRIBUTING.md
14+
15+
# Documentation build artifacts
16+
docs/
17+
*.md
18+
19+
# Build artifacts
20+
dist/
21+
*.tar.gz
22+
*.zip
23+
voiceflow-cli
24+
voiceflow_*
25+
26+
# IDE files
27+
.vscode/
28+
.idea/
29+
*.swp
30+
*.swo
31+
*~
32+
33+
# OS files
34+
.DS_Store
35+
Thumbs.db
36+
37+
# Temporary files
38+
*.tmp
39+
*.temp
40+
.env
41+
.env.local
42+
43+
# Test files
44+
*_test.go
45+
test/
46+
examples/
47+
48+
# Scripts
49+
scripts/
50+
51+
# Makefile
52+
Makefile
53+
54+
# CI/CD
55+
.github/
56+
artifacthub-repo.yml
57+
.golangci.yaml
58+
.grype.yaml

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,18 @@
118118
"transcript", "to-test", "--agent-id", "67213ee4d6009327e23018a9", "--transcript-id", "6776b68b184eadd628bbf98b"
119119
]
120120
},
121+
{
122+
"name": "Server command",
123+
"type": "go",
124+
"request": "launch",
125+
"mode": "debug",
126+
"program": "${workspaceFolder}/main.go",
127+
"env": {
128+
"ENV": "development"
129+
},
130+
"args": [
131+
"server", "--host", "127.0.0.1", "--port", "8080"
132+
]
133+
}
121134
]
122135
}

Makefile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
.PHONY: help build test clean docs serve-docs dev install-tools
2+
3+
# Default target
4+
help: ## Show this help message
5+
@echo "Available targets:"
6+
@awk 'BEGIN {FS = ":.*##"; OFS = ": "} /^[a-zA-Z_-]+:.*##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
7+
8+
# Build the application
9+
build: ## Build the voiceflow-cli binary
10+
@echo "🔨 Building voiceflow-cli..."
11+
go build -o voiceflow-cli .
12+
13+
# Run tests
14+
test: ## Run all tests
15+
@echo "🧪 Running tests..."
16+
go test -v ./...
17+
18+
# Clean build artifacts
19+
clean: ## Clean build artifacts and generated files
20+
@echo "🧹 Cleaning up..."
21+
rm -f voiceflow-cli
22+
rm -rf dist/
23+
24+
# Install development tools
25+
install-tools: ## Install required development tools
26+
@echo "🔧 Installing development tools..."
27+
go install github.com/swaggo/swag/cmd/swag@latest
28+
go install github.com/go-swagger/go-swagger/cmd/swagger@latest
29+
@echo "✅ Development tools installed"
30+
31+
# Generate API documentation
32+
docs: ## Generate OpenAPI/Swagger documentation
33+
@echo "📚 Generating API documentation..."
34+
./scripts/cmd_docs.sh
35+
36+
# Serve documentation locally (requires Python)
37+
serve-docs: docs ## Generate and serve documentation locally
38+
@echo "🌐 Starting documentation server..."
39+
@if command -v python3 >/dev/null 2>&1; then \
40+
cd server/docs && python3 -m http.server 8000 & \
41+
echo "📖 Documentation server started at http://localhost:8000"; \
42+
echo " • swagger.json: http://localhost:8000/swagger.json"; \
43+
echo " • swagger.yaml: http://localhost:8000/swagger.yaml"; \
44+
echo "Press Ctrl+C to stop the server"; \
45+
wait; \
46+
else \
47+
echo "❌ Python3 not found. Please install Python3 to serve docs locally."; \
48+
echo " Alternatively, run 'make dev' to start the API server with Swagger UI"; \
49+
fi
50+
51+
# Development server with live reload
52+
dev: docs ## Build and run development server with Swagger UI
53+
@echo "🚀 Starting development server..."
54+
go run . server --debug --port 8080
55+
@echo "🎉 Server started at http://localhost:8080"
56+
@echo "📖 Swagger UI available at http://localhost:8080/swagger/index.html"
57+
58+
# Build for multiple platforms
59+
build-all: ## Build for multiple platforms
60+
@echo "🏗️ Building for multiple platforms..."
61+
GOOS=linux GOARCH=amd64 go build -o dist/voiceflow-cli-linux-amd64 .
62+
GOOS=darwin GOARCH=amd64 go build -o dist/voiceflow-cli-darwin-amd64 .
63+
GOOS=darwin GOARCH=arm64 go build -o dist/voiceflow-cli-darwin-arm64 .
64+
GOOS=windows GOARCH=amd64 go build -o dist/voiceflow-cli-windows-amd64.exe .
65+
@echo "✅ Multi-platform builds completed in dist/"
66+
67+
# Run linting
68+
lint: ## Run linting
69+
@echo "🔍 Running linters..."
70+
@if command -v golangci-lint >/dev/null 2>&1; then \
71+
golangci-lint run; \
72+
else \
73+
echo "⚠️ golangci-lint not found. Install it with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
74+
fi
75+
76+
# Format code
77+
fmt: ## Format Go code
78+
@echo "✨ Formatting code..."
79+
go fmt ./...
80+
goimports -w .
81+
82+
# Watch for changes and regenerate docs
83+
watch-docs: ## Watch for changes and regenerate docs automatically
84+
@echo "👀 Watching for changes to regenerate docs..."
85+
@if command -v fswatch >/dev/null 2>&1; then \
86+
fswatch -o server/handlers/ server/server.go | xargs -n1 -I{} make docs; \
87+
elif command -v inotifywait >/dev/null 2>&1; then \
88+
while inotifywait -r -e modify server/handlers/ server/server.go; do make docs; done; \
89+
else \
90+
echo "❌ Neither fswatch nor inotifywait found."; \
91+
echo " Install fswatch (macOS: brew install fswatch) or inotify-tools (Linux)"; \
92+
fi
93+
94+
# Validate OpenAPI spec
95+
validate-docs: docs ## Validate generated OpenAPI specification
96+
@echo "✅ Validating OpenAPI specification..."
97+
@if command -v swagger >/dev/null 2>&1; then \
98+
swagger validate server/docs/swagger.yaml; \
99+
else \
100+
echo "⚠️ swagger CLI not found. Install it with: go install github.com/go-swagger/go-swagger/cmd/swagger@latest"; \
101+
echo " Using basic validation..."; \
102+
@if [ -f server/docs/swagger.json ]; then \
103+
echo "📄 swagger.json exists and is valid JSON"; \
104+
else \
105+
echo "❌ swagger.json not found or invalid"; \
106+
fi \
107+
fi

0 commit comments

Comments
 (0)