## Major Achievements ✅ ### Story 1.14: 前端事件画廊页面 - Gallery Page Implementation - ✅ Protected /gallery route with authentication redirect - ✅ Infinite scroll with React Query + Intersection Observer - ✅ Responsive event cards with thumbnail, date, location - ✅ Loading states, empty states, error handling - ✅ Dark theme UI consistent with design system ### Full-Stack Integration Testing Framework - ✅ Docker-based test environment (PostgreSQL + LocalStack) - ✅ E2E tests with Playwright (authentication, gallery workflows) - ✅ API integration tests covering complete user journeys - ✅ Automated test data generation and cleanup - ✅ Performance and concurrency testing ### Technical Stack Validation - ✅ Next.js 15 + React Query + TypeScript frontend - ✅ NestJS + TypeORM + PostgreSQL backend - ✅ AWS S3/SQS integration (LocalStack for testing) - ✅ JWT authentication with secure token management - ✅ Complete data pipeline: Edge → Backend → Processing → Gallery ## Files Added/Modified ### Frontend Implementation - src/app/gallery/page.tsx - Main gallery page with auth protection - src/services/events.ts - API client for events with pagination - src/hooks/use-events.ts - React Query hooks for infinite scroll - src/components/gallery/ - Modular UI components (EventCard, GalleryGrid, States) - src/contexts/query-provider.tsx - React Query configuration ### Testing Infrastructure - docker-compose.test.yml - Complete test environment setup - test-setup.sh - One-command test environment initialization - test-data/seed-test-data.js - Automated test data generation - e2e/gallery.spec.ts - Comprehensive E2E gallery tests - test/integration.e2e-spec.ts - Full-stack workflow validation - TESTING.md - Complete testing guide and documentation ### Project Configuration - package.json (root) - Monorepo scripts and workspace management - playwright.config.ts - E2E testing configuration - .env.test - Test environment variables - README.md - Project documentation ## Test Results 📊 - ✅ Unit Tests: 10/10 passing (Frontend components) - ✅ Integration Tests: Full workflow validation - ✅ E2E Tests: Complete user journey coverage - ✅ Lint: No warnings or errors - ✅ Build: Production ready (11.7kB gallery page) ## Milestone: Epic 1 "First Light" Achieved 🚀 The complete data flow is now validated: 1. User Authentication ✅ 2. Device Registration ✅ 3. Event Upload Pipeline ✅ 4. Background Processing ✅ 5. Gallery Display ✅ This establishes the foundation for all future development. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
119 lines
2.9 KiB
Go
119 lines
2.9 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
// Config holds the application configuration
|
|
type Config struct {
|
|
Port string
|
|
|
|
// Database configuration
|
|
DatabaseURL string
|
|
DatabaseMaxConns int32
|
|
DatabaseTimeout time.Duration
|
|
|
|
// SQS configuration
|
|
SQSQueueURL string
|
|
SQSRegion string
|
|
SQSMaxMessages int32
|
|
SQSWaitTimeSeconds int32
|
|
SQSVisibilityTimeout int32
|
|
|
|
// Processing configuration
|
|
ProcessingWorkers int
|
|
ProcessingBatchSize int
|
|
IdempotencyEnabled bool
|
|
}
|
|
|
|
// Load loads configuration from environment variables with defaults
|
|
func Load() *Config {
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
databaseURL := os.Getenv("DATABASE_URL")
|
|
if databaseURL == "" {
|
|
databaseURL = "postgres://postgres:password@localhost:5432/meteor_development?sslmode=disable"
|
|
}
|
|
|
|
databaseMaxConns := parseInt32(os.Getenv("DATABASE_MAX_CONNS"), 10)
|
|
databaseTimeout := parseDuration(os.Getenv("DATABASE_TIMEOUT"), 30*time.Second)
|
|
|
|
sqsQueueURL := os.Getenv("SQS_QUEUE_URL")
|
|
if sqsQueueURL == "" {
|
|
sqsQueueURL = "https://sqs.us-east-1.amazonaws.com/123456789012/meteor-raw-events-queue"
|
|
}
|
|
|
|
sqsRegion := os.Getenv("SQS_REGION")
|
|
if sqsRegion == "" {
|
|
sqsRegion = "us-east-1"
|
|
}
|
|
|
|
sqsMaxMessages := parseInt32(os.Getenv("SQS_MAX_MESSAGES"), 10)
|
|
sqsWaitTimeSeconds := parseInt32(os.Getenv("SQS_WAIT_TIME_SECONDS"), 20)
|
|
sqsVisibilityTimeout := parseInt32(os.Getenv("SQS_VISIBILITY_TIMEOUT"), 300)
|
|
|
|
processingWorkers := parseInt(os.Getenv("PROCESSING_WORKERS"), 5)
|
|
processingBatchSize := parseInt(os.Getenv("PROCESSING_BATCH_SIZE"), 10)
|
|
idempotencyEnabled := parseBool(os.Getenv("IDEMPOTENCY_ENABLED"), true)
|
|
|
|
return &Config{
|
|
Port: port,
|
|
DatabaseURL: databaseURL,
|
|
DatabaseMaxConns: databaseMaxConns,
|
|
DatabaseTimeout: databaseTimeout,
|
|
SQSQueueURL: sqsQueueURL,
|
|
SQSRegion: sqsRegion,
|
|
SQSMaxMessages: sqsMaxMessages,
|
|
SQSWaitTimeSeconds: sqsWaitTimeSeconds,
|
|
SQSVisibilityTimeout: sqsVisibilityTimeout,
|
|
ProcessingWorkers: processingWorkers,
|
|
ProcessingBatchSize: processingBatchSize,
|
|
IdempotencyEnabled: idempotencyEnabled,
|
|
}
|
|
}
|
|
|
|
// Helper functions for parsing environment variables
|
|
func parseInt(s string, defaultValue int) int {
|
|
if s == "" {
|
|
return defaultValue
|
|
}
|
|
if val, err := strconv.Atoi(s); err == nil {
|
|
return val
|
|
}
|
|
return defaultValue
|
|
}
|
|
|
|
func parseInt32(s string, defaultValue int32) int32 {
|
|
if s == "" {
|
|
return defaultValue
|
|
}
|
|
if val, err := strconv.ParseInt(s, 10, 32); err == nil {
|
|
return int32(val)
|
|
}
|
|
return defaultValue
|
|
}
|
|
|
|
func parseBool(s string, defaultValue bool) bool {
|
|
if s == "" {
|
|
return defaultValue
|
|
}
|
|
if val, err := strconv.ParseBool(s); err == nil {
|
|
return val
|
|
}
|
|
return defaultValue
|
|
}
|
|
|
|
func parseDuration(s string, defaultValue time.Duration) time.Duration {
|
|
if s == "" {
|
|
return defaultValue
|
|
}
|
|
if val, err := time.ParseDuration(s); err == nil {
|
|
return val
|
|
}
|
|
return defaultValue
|
|
} |