Repository navigation
Expand file tree
/
Copy path.env.example
More file actions
262 lines (229 loc) · 10.6 KB
/
Copy path.env.example
File metadata and controls
262 lines (229 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# --- Stellar / Soroban ---
Stellar_NETWORK=testnet
# Required: Stellar secret key (S...) used to sign update_impact_score transactions
ADMIN_SECRET_KEY=
# Required: Soroban contract address for the ProjectRegistry
PROJECT_REGISTRY_CONTRACT_ID=
# Optional: Soroban contract address for the InvestmentVault (required for /v1/portfolio endpoint)
INVESTMENT_VAULT_CONTRACT_ID=
# Optional: Stellar RPC endpoint. Default: https://soroban-testnet.stellar.org
RPC_URL= https://soroban-testnet.stellar.org
# --- PostgreSQL connection (migrations) ---
# Required for staging/production; defaults are used for local development.
# If DB_NAME is unset, defaults to heliobond_dev in development and heliobond_test in test.
DB_HOST=localhost
DB_PORT=5432
DB_NAME=
DB_USER=postgres
DB_PASSWORD=
# --- HTTP server ---
# Optional: Port the API listens on. Default: 3001
PORT=3001
# Optional: Origin allowed by CORS. Default: http://localhost:3000
FRONTEND_URL= http://localhost:3000
# Optional: Bearer token for /api/admin/*. If unset, admin auth is skipped (dev only).
ADMIN_API_KEY=
# --- GraphQL query safety ---
# Maximum nested selection depth per GraphQL operation. Default: 12
GRAPHQL_MAX_DEPTH=12
# Maximum field selections (aliases and fragments included) per operation. Default: 1000
GRAPHQL_MAX_COMPLEXITY=1000
# Maximum root fields/aliases per operation. Default: 20
GRAPHQL_MAX_ROOT_FIELDS=20
# Introspection (__schema/__type) defaults to disabled when NODE_ENV=production
# and enabled otherwise. Set "true" to allow it in production, "false" to disable everywhere.
# __typename is always allowed.
GRAPHQL_ALLOW_INTROSPECTION=
# Optional: request timeout in milliseconds (default 30000; admin routes default 60000)
REQUEST_TIMEOUT_MS=30000
ADMIN_REQUEST_TIMEOUT_MS=60000
# WebSocket bearer token for /ws connection. Sent as `Authorization: Bearer <token>`.
# No query string (?token=) support. Required in production; if unset, WebSocket auth is
# skipped in dev/test. Does NOT fall back to ADMIN_API_KEY.
WS_AUTH_TOKEN=
# Creator endpoints require a signed wallet challenge
# (x-wallet-signature + x-wallet-timestamp) in addition to x-wallet-address
# by default (#832). Set to "false" ONLY in local dev or tests — doing so
# accepts any client-chosen Stellar address as the creator identity.
WALLET_AUTH_REQUIRE_SIGNATURE=true
# --- RBAC ---
# Optional: User ID to grant the "admin" role at startup. This bootstraps the
# RBAC system, since the admin role is required to manage roles and there is
no other way to create the first admin. If unset, no initial admin is seeded.
INITIAL_ADMIN_USER_ID=
# --- Rate limiting (optional; sensible defaults applied when unset) ---
# Public endpoints: window length and max requests per IP per window
RATE_LIMIT_WINDOW_MS=60000
RATE_LIMIT_MAX=100
# Admin endpoints: stricter limits (default window mirrors RATE_LIMIT_WINDOW_MS)
RATE_LIMIT_ADMIN_WINDOW_MS=60000
RATE_LIMIT_ADMIN_MAX=20
# --- Reverse Proxy / Trust Proxy ---
# Trust proxy configuration for Express (req.ip / rate limiting / IP whitelist).
# Values: "false" (default, no proxy), "true" (trust all proxies), "loopback",
# a CIDR / IP list (e.g. "10.0.0.0/8, 172.16.0.0/12"), or hop count number (e.g. "1")
TRUST_PROXY=false
# --- IP Whitelist for admin endpoints (optional) --
# Comma-separated list of allowed IPs or CIDR ranges
# If empty or unset, IP whitelist is disabled (all IPs allowed)
ADMIN_IP_WHITELIST=
# Set to "false" to NOT bypass private/internal networks (default: true bypasses them)
ADMIN_IP_WHITELIST_BYPASS_PRIVATE=true
# --- Request Signing (optional) --
# HMAC secret for request signature verification
# If empty or unset, request signing is disabled
REQUEST_SIGNING_SECRET=
# --- APM (Application Performance Monitoring) ---
# APM provider: "datadog" | "newrelic" | "opentelemetry" | "none"
APM_PROVIDER=none
# DataDog APM (if APM_PROVIDER=datadog)
DD_AGENT_HOST=localhost
DD_SERVICE=heliobond-backend
DD_ENV=development
DD_VERSION=1.0.0
# New Relic (if APM_PROVIDER=newrelic)
NEW_RELIC_LICENSE_KEY
NEW_RELIC_APP_NAME=heliobond-backend
# OpenTelemetry (if APM_PROVIDER=opentelemetry)
OTEL_EXPORTER_OLTP_ENDPOINT=http://localhost:4318
OTEL_SERVICE_NAME=heliobond-backend
# --- Circuit Breaker ---
# Number of consecutive RFC failures before opening the circuit. Default: 5
CIRCUIT_BREAKER_THRESHOLD=5
# Cooldown (ms) before the circuit moves from OPEN to HALF_OPEN. Default: 30000
CIRCUIT_BREAKER_COOLDOWN_MS=30000
# --- Logging ---
# Log level: debug | info | warn | error
# Defaults to environment-based: development=debug, staging=info, production=warn
LOG_LEVEL=
# --- Body size limit --
# Maximum request body size accepted by express.json()
# Accepts any string parsable by bytes library (e.g. "100kb", "1mb", "50kb")
BOPY_SIZE_LIMIT=100kb
# Accepts any string parseable by bytes library (e.g. "100kb", "1mb", "50kb")
BODY_SIZE_LIMIT=100kb
# --- Frontend telemetry ingest (#770) --
# Max body size for POST /v1/telemetry (text/plain beacons and JSON). Default: 64kb
TELEMETRY_BODY_SIZE_LIMIT=64kb
# Set to "true" to also forward accepted reports to the configured OTLP exporter. Default: false
TELEMETRY_OTLP_ENABLED=false
# Per-IP rate limit for the telemetry ingest route.
# Window defaults to RATE_LIMIT_WINDOW_MS; max defaults to 120 requests per window.
TELEMETRY_RATE_LIMIT_WINDOW_MS=60000
TELEMETRY_RATE_LIMIT_MAX=120
# The frontend (separate repository) should point its beacon URL at this endpoint:
# NEXT_PUBLIC_ERROR_REPORT_URL=https://api.heliobond.example/v1/telemetry
# --- CSRF Protection ---
# Comma-separated list of allowed origins for CSRF validation
CORS_ORIGINS=
# --- Stellar transaction polling ---
# Optional: How long (ms) to wait between polling for transaction confirmation. Default: 1500
POLL_INTERVAL_MS=1500
# Optional: Max number of polling attempts before timing out. Default: 20
POLL_MAX_ATTEMPT_PS=20
# --- Stellar transaction timeout ---
# Optional: Transaction timeout in seconds for Soroban contract calls. Default: 30
TX_TIMEOUT_SECONDS=30
# --- Stellar transaction retries (optional) --
# Optional: Max retry attempts for failed Stellar transactions. Default: 10
TX_MAX_RETRIES=10
# Optional: Base delay (ms) for exponential backoff between retries. Default: 200
TX_RETRY_BASE_DELAY_MS=200
# Optional: Max delay (ms) cap for retry backoff.
# Optional: Max delay (ms) cap for retry backoff. Default: 10000
TX_RETRY_MAX_DELAY_MS=10000
# --- Stellar RPC retries (optional) ---
# Optional: Max retry attempts for transient RPC errors (timeouts, 503s, network blips). Default: 3
RPC_MAX_RETRIES=3
# Optional: Base delay (ms) for exponential backoff on RPC retries. Default: 1000
RPC_RETRY_BASE_MS=1000
# --- Stellar RPC connection pool (optional; pool for lib/db-pool.ts) ---
# Optional: Minimum number of pooled connections. Default: 2
DB_POOL_MIN=2
# Optional: Maximum number of pooled connections. Default: 10
DB_POOL_MAX=10
# Optional: Timeout (ms) to acquire a connection from the pool. Default: 5000
DB_POOL_ACQUIRE_TIMEOUT_MS=5000
# Optional: Interval (ms) for pool health checks. Default: 30000
DB_POOL_HEALTH_CHECK_INTERVAL_MS=30000
# --- Database SSL (optional) ---
# Path to the CA certificate file for the database server.
# Required when the database uses a private CA (e.g., AWS RDS, GCP Cloud SQL)
# and the certificate is not in the system trust store.
# Set this to enable proper TLS certificate validation.
DB_SSL_CA_PATH=
# Optional: Database connection pool timeout settings
DB_ACQUIRE_TIMEOUT_MS=30000
DB_IDLE_TIMEOUT_MS=60000
# --- Idempotency (optional) ---
# Optional: TTL (ms) for the in-memory idempotency key store.
# Duplicate score update submissions for the same project within this window
# are rejected before reaching Stellar RPC. Default: 3600000 (1 hour)
IDEMPOTENCY_TTL_MS=3600000
# --- Cron (optional) ---
# Optional: Timezone for scheduled cron jobs. Default: UTC
CRON_TIMEZONE=UTC
# Optional: Failure threshold ratio (0..1) for cron health checks. Default: 0.5
CRON_FAILURE_THRESHOLD=0.5
# --- Graceful shutdown (optional) --
# Optional: Timeout (ms) to wait for graceful shutdown before forcing exit. Default: 30000
SHUTDOWN_TIMEOUT_MS=30000
# --- IoT simulation ---
# Optional: Maximum simulated solar power output in kW. Default: 1000
MAX_POWER_KW=1000
# Optional: Set to "true" to disable the in-memory IoT reading cache.
# Readings are deterministic per (project_id, hour), so the cache only skips
# redundant recomputation -- disabling it changes performance, not responses.
IOT_CACHE_DISABLED=
# Optional: Max entries retained by the IoT reading cache. Default: 1000
# Oldest entries are evicted first once the cap is reached.
IOT_CACHE_MAX_SIZE=1000
# --- Input validation ---
# Optional: Inclusive upper bound accepted for a :payload project parameter.
# Requests outside 1..MAX_PROJECT_ID are rejected with HTTP 400. Default: 1000000
MAX_PROJECT_ID=1000000
# --- Secrets Management --
# Provider: env | aws | vault | azure
SECRETS_PROVIDER=env
# AWS Secrets Manager (if SECRETS_PROVIDER=aws)
AWS_REGION=us-east-1
AWS_SECRET_ID=
AWS_SECRET_VERSION_ID=
# HashiCorp Vault (if SECRETS_PROVIDER=vault)
VAULT_ENDPOINT=http://localhost:8200
VAULT_TOKEN=
VAULT_SECRET_PATH=secret/data/heliobond
# Azure Key Vault (if SECRETS_PROVIDER=azure)
AZURE_VAULT_URL=
AZURE_TENANT_ID=
AZURE_CLIENT_ID=
AZURE_CLIENT_SECRET=
# Secret rotation (optional)
SECRETS_ROTATION_ENABLED=false
SECRETS_ROTATION_INTERVAL_MS=3600000
# Vault event indexer: persist indexed events to Postgres for GET /v1/investors/:address/activity
# (needs the DB_* settings and migrations applied; the endpoints return 503 while disabled).
VAULT_EVENT_INDEXER_ENABLED=false
# First ledger to backfill from when no cursor has been stored yet.
VAULT_EVENT_INDEXER_START_LEDGER=0
# --- gRPC Server (optional) ---
# Optional: Port for the gRPC server. Default: 50051
GRPC_PORT=50051
# --- RPC Monitoring (optional) ---
# Optional: Extended RPC outage threshold in milliseconds. Default: 300000 (5 minutes)
RPC_OUTAGE_THRESHOLD_MS=300000
# --- Health Check (optional) ---
# Optional: Migration health check timeout in milliseconds. Default: 1000
HEALTH_CHECK_TIMEOUT_MS=1000
# --- Batch Job Store (optional) ---
# Optional: TTL for completed/failed batch jobs in milliseconds. Default: 3600000 (1 hour)
BATCH_JOB_TTL_MS=3600000
# Optional: Maximum number of batch jobs to keep in memory. Default: 1000
BATCH_JOB_MAX_SIZE=1000
# --- Webhook Store (optional) ---
# Optional: Cleanup interval for stale webhooks in milliseconds. Default: 3600000 (1 hour)
WEBHOOK_CLEANUP_INTERVAL_MS=3600000
# Optional: Threshold for considering a webhook stale in milliseconds. Default: 86400000 (24 hours)
WEBHOOK_STALE_THRESHOLD_MS=86400000
# Max events retained in the in-memory store; oldest are evicted FIFO past this cap.
VAULT_EVENT_INDEXER_MAX_EVENTS=1000