86211923db
Repository Interface Optimization: - Created IBaseRepository.ts and IPaginatedRepository.ts - Refactored all 7 repository interfaces to extend base interfaces - Eliminated ~200 lines of redundant code (70% reduction) - Improved type safety and maintainability Dependency Injection Improvements: - Added EmailService and GameTokenService to DIContainer - Updated CreateUserCommandHandler constructor for DI - Updated RequestPasswordResetCommandHandler constructor for DI - Enhanced testability and service consistency Environment Configuration: - Created comprehensive .env.example with 40+ variables - Organized into 12 logical sections (Database, Security, Email, etc.) - Added security guidelines and best practices - Documented all backend environment requirements Documentation: - Added comprehensive codebase review - Created refactoring summary report - Added frontend implementation guide Impact: Improved code quality, reduced maintenance overhead, enhanced developer experience
222 lines
6.2 KiB
Bash
222 lines
6.2 KiB
Bash
# ==============================================
|
|
# SerpentRace Backend Environment Configuration
|
|
# ==============================================
|
|
# Copy this file to .env and fill in your values
|
|
# This file contains all environment variables used by the backend
|
|
|
|
# ==============================================
|
|
# APPLICATION CONFIGURATION
|
|
# ==============================================
|
|
|
|
# Node.js environment (development, production, test)
|
|
NODE_ENV=development
|
|
|
|
# Server port number
|
|
PORT=3000
|
|
|
|
# Base URL for the application (used for email links, etc.)
|
|
APP_BASE_URL=http://localhost:3000
|
|
|
|
# ==============================================
|
|
# DATABASE CONFIGURATION (PostgreSQL)
|
|
# ==============================================
|
|
|
|
# Database connection details
|
|
DB_HOST=localhost
|
|
DB_PORT=5432
|
|
DB_NAME=serpentrace
|
|
DB_USERNAME=postgres
|
|
DB_PASSWORD=your_db_password
|
|
|
|
# Database URL (alternative to individual settings)
|
|
# DATABASE_URL=postgresql://username:password@localhost:5432/serpentrace
|
|
|
|
# ==============================================
|
|
# REDIS CONFIGURATION
|
|
# ==============================================
|
|
|
|
# Redis connection details (for caching and sessions)
|
|
REDIS_HOST=localhost
|
|
REDIS_PORT=6379
|
|
|
|
# Redis URL (alternative to individual settings)
|
|
REDIS_URL=redis://localhost:6379
|
|
|
|
# Redis password (if required)
|
|
# REDIS_PASSWORD=your_redis_password
|
|
|
|
# ==============================================
|
|
# JWT (JSON Web Token) CONFIGURATION
|
|
# ==============================================
|
|
|
|
# Secret key for JWT signing (REQUIRED - use a strong, random key in production)
|
|
JWT_SECRET=your_super_secret_jwt_key_change_in_production
|
|
|
|
# JWT token expiration time
|
|
# Can be specified in seconds (e.g., 86400) or time format (e.g., 24h, 7d, 30m)
|
|
JWT_EXPIRY=86400
|
|
# Alternative format
|
|
JWT_EXPIRATION=24h
|
|
|
|
# JWT refresh token expiration (for future use)
|
|
JWT_REFRESH_EXPIRATION=7d
|
|
|
|
# Game token expiration (for game session tokens)
|
|
GAME_TOKEN_EXPIRY=86400
|
|
|
|
# ==============================================
|
|
# EMAIL SERVICE CONFIGURATION (SMTP)
|
|
# ==============================================
|
|
|
|
# SMTP server configuration
|
|
EMAIL_HOST=smtp.gmail.com
|
|
EMAIL_PORT=587
|
|
EMAIL_SECURE=false
|
|
|
|
# Email authentication
|
|
EMAIL_USER=your_email@domain.com
|
|
EMAIL_PASS=your_email_password
|
|
|
|
# From address for outgoing emails
|
|
EMAIL_FROM=noreply@serpentrace.com
|
|
|
|
# ==============================================
|
|
# CHAT SYSTEM CONFIGURATION
|
|
# ==============================================
|
|
|
|
# Chat inactivity timeout (in minutes)
|
|
CHAT_INACTIVITY_TIMEOUT_MINUTES=30
|
|
|
|
# Maximum messages per user per session
|
|
CHAT_MAX_MESSAGES_PER_USER=100
|
|
|
|
# Cleanup old messages after X weeks
|
|
CHAT_MESSAGE_CLEANUP_WEEKS=4
|
|
|
|
# ==============================================
|
|
# GAME CONFIGURATION
|
|
# ==============================================
|
|
|
|
# Board generation settings
|
|
MAX_SPECIAL_FIELDS_PERCENTAGE=67
|
|
MAX_GENERATION_TIME_SECONDS=20
|
|
GENERATION_ERROR_TOLERANCE=15
|
|
|
|
# ==============================================
|
|
# MINIO/S3 CONFIGURATION (File Storage)
|
|
# ==============================================
|
|
|
|
# MinIO server configuration (for file uploads)
|
|
MINIO_ENDPOINT=localhost
|
|
MINIO_PORT=9000
|
|
MINIO_ACCESS_KEY=serpentrace
|
|
MINIO_SECRET_KEY=serpentrace123!
|
|
MINIO_USE_SSL=false
|
|
|
|
# S3 bucket name (if using S3 instead of MinIO)
|
|
# S3_BUCKET_NAME=serpentrace-files
|
|
|
|
# ==============================================
|
|
# LOGGING CONFIGURATION
|
|
# ==============================================
|
|
|
|
# Log level (error, warn, info, debug)
|
|
LOG_LEVEL=info
|
|
|
|
# Log file retention (in days)
|
|
LOG_RETENTION_DAYS=30
|
|
|
|
# ==============================================
|
|
# SECURITY CONFIGURATION
|
|
# ==============================================
|
|
|
|
# API rate limiting (requests per minute per IP)
|
|
RATE_LIMIT_RPM=60
|
|
|
|
# Maximum file upload size (in MB)
|
|
MAX_UPLOAD_SIZE_MB=10
|
|
|
|
# CORS allowed origins (comma-separated)
|
|
CORS_ORIGINS=http://localhost:3000,http://localhost:3001,http://localhost:8080
|
|
|
|
# ==============================================
|
|
# ADMIN CONFIGURATION
|
|
# ==============================================
|
|
|
|
# Admin bypass settings
|
|
ADMIN_BYPASS_ENABLED=true
|
|
|
|
# Default admin user (for development only)
|
|
# ADMIN_DEFAULT_EMAIL=admin@serpentrace.com
|
|
# ADMIN_DEFAULT_PASSWORD=change_this_password
|
|
|
|
# ==============================================
|
|
# MONITORING & HEALTH CHECKS
|
|
# ==============================================
|
|
|
|
# Health check endpoint timeout (in milliseconds)
|
|
HEALTH_CHECK_TIMEOUT=5000
|
|
|
|
# Database connection pool settings
|
|
DB_CONNECTION_POOL_MIN=2
|
|
DB_CONNECTION_POOL_MAX=10
|
|
|
|
# ==============================================
|
|
# DEVELOPMENT ONLY SETTINGS
|
|
# ==============================================
|
|
# These settings should only be used in development
|
|
|
|
# Enable detailed SQL logging
|
|
DB_LOGGING=true
|
|
|
|
# Enable debug mode for various services
|
|
DEBUG_MODE=false
|
|
|
|
# Disable email sending in development (logs emails instead)
|
|
EMAIL_DEBUG_MODE=true
|
|
|
|
# ==============================================
|
|
# PRODUCTION ONLY SETTINGS
|
|
# ==============================================
|
|
# These settings are typically used only in production
|
|
|
|
# Enable HTTPS (for production)
|
|
# HTTPS_ENABLED=true
|
|
# SSL_CERT_PATH=/path/to/cert.pem
|
|
# SSL_KEY_PATH=/path/to/key.pem
|
|
|
|
# Sentry configuration (for error tracking)
|
|
# SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id
|
|
|
|
# New Relic configuration (for performance monitoring)
|
|
# NEW_RELIC_LICENSE_KEY=your_new_relic_license_key
|
|
# NEW_RELIC_APP_NAME=SerpentRace Backend
|
|
|
|
# ==============================================
|
|
# EXTERNAL API KEYS (Optional)
|
|
# ==============================================
|
|
|
|
# Third-party service API keys (if used)
|
|
# ANALYTICS_API_KEY=your_analytics_key
|
|
# PAYMENT_API_KEY=your_payment_processor_key
|
|
|
|
# ==============================================
|
|
# NOTES & SECURITY WARNINGS
|
|
# ==============================================
|
|
|
|
# SECURITY NOTES:
|
|
# - Never commit .env files to version control
|
|
# - Use strong, unique passwords and keys
|
|
# - Regularly rotate JWT secrets and API keys
|
|
# - Use environment-specific values for each deployment
|
|
|
|
# REQUIRED VARIABLES:
|
|
# The following variables are required for the application to start:
|
|
# - NODE_ENV
|
|
# - DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD
|
|
# - REDIS_HOST, REDIS_PORT
|
|
# - JWT_SECRET
|
|
# - EMAIL_HOST, EMAIL_PORT, EMAIL_USER, EMAIL_PASS
|
|
|
|
# OPTIONAL VARIABLES:
|
|
# All other variables have sensible defaults and are optional |