SIP_GoldBees_Backend/backend/run_backend.ps1

32 lines
1.7 KiB
PowerShell

Set-Location $PSScriptRoot
$appEnv = if ($env:APP_ENV) { $env:APP_ENV } else { 'development' }
if (-not $env:APP_ENV) { $env:APP_ENV = $appEnv }
if (-not $env:DB_HOST) { $env:DB_HOST = 'localhost' }
if (-not $env:DB_PORT) { $env:DB_PORT = '5432' }
if (-not $env:DB_NAME) { $env:DB_NAME = 'trading_db' }
if (-not $env:DB_USER) { $env:DB_USER = 'trader' }
if (-not $env:DB_PASSWORD) { $env:DB_PASSWORD = 'traderpass' }
if (-not $env:DB_SCHEMA) { $env:DB_SCHEMA = 'quant_app' }
if (-not $env:DB_CONNECT_TIMEOUT) { $env:DB_CONNECT_TIMEOUT = '5' }
$frontendUrlFile = Join-Path (Split-Path -Parent $PSScriptRoot) 'ngrok_frontend_url.txt'
$env:ZERODHA_REDIRECT_URL = 'http://localhost:3000/login'
if (Test-Path $frontendUrlFile) {
$frontendUrl = (Get-Content $frontendUrlFile -Raw).Trim()
if ($frontendUrl) {
$env:CORS_ORIGINS = "http://localhost:3000,http://127.0.0.1:3000,$frontendUrl"
$env:COOKIE_SECURE = '1'
$env:COOKIE_SAMESITE = 'none'
$env:ZERODHA_REDIRECT_URL = "$frontendUrl/login"
}
}
if (-not $env:SMTP_HOST) { $env:SMTP_HOST = 'smtp.gmail.com' }
if (-not $env:SMTP_PORT) { $env:SMTP_PORT = '587' }
if (-not $env:SMTP_FROM_NAME) { $env:SMTP_FROM_NAME = 'Quantfortune Support' }
if (-not $env:BROKER_TOKEN_KEY -and $env:APP_ENV -in @('development', 'dev', 'test', 'testing', 'local')) {
$env:BROKER_TOKEN_KEY = (& .\venv\Scripts\python.exe -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode('utf-8'))").Trim()
}
if (-not $env:RESET_OTP_SECRET -and $env:APP_ENV -in @('development', 'dev', 'test', 'testing', 'local')) {
$env:RESET_OTP_SECRET = 'dev-reset-otp-secret'
}
.\venv\Scripts\uvicorn.exe app.main:app --host 0.0.0.0 --port 8000