diff --git a/backend/.env.example b/backend/.env.example index 5035a28b..968d01a5 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -1,7 +1,22 @@ -# Database +# ─── Server ─────────────────────────────────────────────────────────────────── +# Port the Express server listens on (default: 3001) +PORT=3001 + +# Application environment mode ('development', 'production', or 'test') +NODE_ENV=development + +# Comma-separated list of allowed origins for CORS. In development, if unset, +# defaults to http://localhost:3000 +CORS_ALLOWED_ORIGINS="https://app.flowfi.xyz,https://flowfi.xyz" + +# Optional base URL for Swagger OpenAPI documentation server (e.g. http://localhost:3001) +API_BASE_URL=http://localhost:3001 + +# ─── Database ───────────────────────────────────────────────────────────────── +# Main PostgreSQL database connection URL DATABASE_URL="postgresql://user:password@localhost:5433/flowfi?schema=public" -# PostgreSQL pool settings +# PostgreSQL pool settings: # Maximum database connections per backend process (default: 10) PG_POOL_MAX=10 # How long an idle connection stays open before being closed (milliseconds, default: 30000) @@ -11,51 +26,58 @@ PG_CONNECTION_TIMEOUT_MS=5000 # Maximum time a PostgreSQL statement may run before cancellation (milliseconds, default: 30000) PG_STATEMENT_TIMEOUT_MS=30000 -# Server -PORT=3001 -NODE_ENV=development -CORS_ALLOWED_ORIGINS="https://app.flowfi.xyz,https://flowfi.xyz" -# Comma-separated list of allowed origins for CORS. In development, if unset, -# defaults to http://localhost:3000 - -# Stellar Network (Testnet/Mainnet) +# ─── Stellar & Soroban ──────────────────────────────────────────────────────── +# Stellar network target ('testnet' or 'mainnet') STELLAR_NETWORK=testnet -STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org - -# Enable sandbox mode -SANDBOX_MODE_ENABLED=true -# Optional: Use a separate database for sandbox -# If not set, it will use {DATABASE_URL}_sandbox -SANDBOX_DATABASE_URL="postgresql://user:password@localhost:5433/flowfi_sandbox?schema=public" +# Stellar Horizon REST API server endpoint +STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org -# ─── Soroban Event Indexer ──────────────────────────────────────────────────── -# Soroban RPC endpoint (testnet default shown) +# Soroban RPC endpoint URL (testnet default shown) SOROBAN_RPC_URL=https://soroban-testnet.stellar.org -# Deployed FlowFi stream contract address (C...) -# Leave empty to disable the event indexer +# Deployed FlowFi stream contract address (C...). Leave empty to disable indexers STREAM_CONTRACT_ID= -# How often the indexer polls for new events (milliseconds, default: 5000) +# Server-side Stellar secret key (S...) used to sign and submit on-chain transactions +# (cancel_stream, top_up_stream). Must be funded on the target network. +KEEPER_SECRET_KEY= + +# Max stream creation requests per wallet per minute (default: 10) +STREAM_CREATE_RATE_LIMIT=10 + +# Timeout for Soroban RPC requests in milliseconds (default: 10000) +SOROBAN_RPC_TIMEOUT_MS=10000 + +# Maximum retry attempts for failed Soroban RPC requests (default: 2) +SOROBAN_RPC_MAX_RETRIES=2 + +# Base delay in milliseconds for exponential backoff during Soroban RPC retries (default: 250) +SOROBAN_RPC_RETRY_BASE_MS=250 + +# ─── Soroban Event Indexer ──────────────────────────────────────────────────── +# Polling interval in milliseconds for the background Soroban event worker (default: 5000) INDEXER_POLL_INTERVAL_MS=5000 -# Ledger sequence to start indexing from on first run (0 = latest) +# Ledger sequence for event worker to start indexing from on first run (0 = latest, default: 0) INDEXER_START_LEDGER=0 -# Max stream creation requests per wallet per minute (default: 10) -STREAM_CREATE_RATE_LIMIT=10 +# Polling interval in milliseconds for Soroban indexer service (default: 15000) +SOROBAN_INDEXER_POLL_MS=15000 -# Server-side Stellar secret key used to sign and submit on-chain transactions -# (cancel_stream, top_up_stream). Must be funded on the target network. -KEEPER_SECRET_KEY= +# Ledger sequence to start indexing from for Soroban indexer service (default: 0) +SOROBAN_INDEXER_START_LEDGER=0 # ─── Auth ───────────────────────────────────────────────────────────────────── -# Secret used to sign JWTs (generate with: openssl rand -hex 32) +# Secret used to sign JWTs (generate with: openssl rand -hex 32). Required in production. JWT_SECRET= -# Stellar public key of the admin user (for /v1/admin/* endpoints) +# Stellar public key (G...) of the admin user (for /v1/admin/* endpoints) ADMIN_PUBLIC_KEY= + +# Interval in milliseconds to sweep and prune expired auth challenges (default: 300000) +AUTH_CHALLENGE_SWEEP_INTERVAL_MS=300000 + # ─── Redis (optional) ──────────────────────────────────────────────────────── # When set, enables horizontal SSE scaling via Redis pub/sub so events # emitted by any backend instance are broadcast to clients on all instances. @@ -63,8 +85,36 @@ ADMIN_PUBLIC_KEY= REDIS_URL= # ─── Caching (optional) ─────────────────────────────────────────────────────── -# Time in milliseconds between periodic sweeps to prune expired memory cache -# entries (default: 60000) +# Time in milliseconds between periodic sweeps to prune expired memory cache entries (default: 60000) MEMORY_CACHE_SWEEP_MS=60000 +# Cache time-to-live (TTL) for claimable amount calculations in milliseconds (default: 5000) +CLAIMABLE_CACHE_TTL_MS=5000 + +# ─── Logging ────────────────────────────────────────────────────────────────── +# Log output verbosity level ('error', 'warn', 'info', 'debug', default: info) +LOG_LEVEL=info + +# ─── Streaming & Server-Sent Events (SSE) ───────────────────────────────────── +# Maximum concurrent SSE client connections allowed (default: 10000) +MAX_SSE_CONNECTIONS=10000 + +# ─── Sandbox Mode ───────────────────────────────────────────────────────────── +# Enable or disable sandbox mode ('true' or 'false', default: true) +SANDBOX_MODE_ENABLED=true + +# Optional: Separate PostgreSQL connection URL for sandbox mode. +# If not set, defaults to {DATABASE_URL}_sandbox +SANDBOX_DATABASE_URL="postgresql://user:password@localhost:5433/flowfi_sandbox?schema=public" + +# Whether sandbox mode can be triggered via request headers ('true' or 'false', default: true) +SANDBOX_ALLOW_HEADER=true + +# Whether sandbox mode can be triggered via query parameters ('true' or 'false', default: true) +SANDBOX_ALLOW_QUERY_PARAM=true + +# Header name used to trigger sandbox mode (default: X-Sandbox-Mode) +SANDBOX_HEADER_NAME=X-Sandbox-Mode +# Query parameter name used to trigger sandbox mode (default: sandbox) +SANDBOX_QUERY_PARAM_NAME=sandbox