配置
rCommerce 通过 TOML 文件配置。每个选项都有合理的默认值。
按优先级从高到低:
RCOMMERCE_CONFIG环境变量指定的路径./config/default.toml./config/production.toml/etc/rcommerce/config.toml
Server
Section titled “Server”[server]host = "0.0.0.0" # 绑定地址port = 8080 # 监听端口worker_threads = 0 # 0 = 使用 CPU 核数
[server.cors]enabled = trueallowed_origins = ["*"]allowed_methods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]allowed_headers = ["Content-Type", "Authorization"]Database
Section titled “Database”[database]db_type = "Postgres"host = "localhost"port = 5432database = "rcommerce"username = "rcommerce"password = "password"pool_size = 20[cache]cache_type = "Memory" # 或 "Redis"max_size_mb = 100redis_url = "redis://localhost:6379"Security
Section titled “Security”[security]api_key_prefix_length = 40api_key_secret_length = 40
[security.jwt]secret = "change-this-in-production"expiry_hours = 24Payment
Section titled “Payment”[payment]default_gateway = "airwallex" # 或 "stripe" / "mock"test_mode = true
[payment.stripe]enabled = truesecret_key = "sk_test_..."publishable_key = "pk_test_..."
[payment.airwallex]enabled = falseclient_id = ""api_key = ""webhook_secret = ""demo = trueOrders
Section titled “Orders”[orders]# 未支付(待付款)订单经过这么多分钟后自动取消,释放库存预留。# 不设置 = 清扫器停用。auto_cancel_pending_minutes = 120Accounting
Section titled “Accounting”[accounting]store_code = "SHOP" # 账单/订单引用中的短代码store_name = "My Shop" # 会计导出中的店铺名site_url = "https://shop.example.com" # 嵌入支付服务商元数据这些值作用于 会计导出参考中的导出和 结算同步端点。
Shipping
Section titled “Shipping”[shipping]default_provider = "weight_based"
[shipping.weight_based]# 分区运费在代码中配置# 详见物流指南Notifications
Section titled “Notifications”[notifications]enabled = true
[notifications.email]# 方式 1:Postmark(推荐——无需维护 SMTP 服务器)postmark_token = "your-server-token"postmark_stream = "outbound" # 可选,默认 "outbound"from_email = "[email protected]"from_name = "Your Store"
# 方式 2:SMTPsmtp_host = "smtp.example.com"smtp_port = 465 # 465 = 隐式 TLS (SMTPS),587 = STARTTLSsmtp_user = "[email protected]"smtp_pass = "password"smtp_tls = truePostmark 和 SMTP 二选一:设置 postmark_token 即通过 Postmark API
发送,或设置 smtp_* 通过 SMTP 发送。
Features
Section titled “Features”[features]debug_api = true # 启用调试端点metrics = true # Prometheus 指标health_check = true # /health 端点[tls]enabled = falsecert_path = "/path/to/cert.pem"key_path = "/path/to/key.pem"