EV 충전 플랫폼 초기 백업
This commit is contained in:
70
app/config.py
Normal file
70
app/config.py
Normal file
@@ -0,0 +1,70 @@
|
||||
"""설정 관리 — 환경변수 기반"""
|
||||
|
||||
from pydantic_settings import BaseSettings
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
# DB
|
||||
POSTGRES_DB: str = "ev_charging"
|
||||
POSTGRES_USER: str = "evuser"
|
||||
POSTGRES_PASSWORD: str = "evpass1234"
|
||||
POSTGRES_HOST: str = "postgres"
|
||||
POSTGRES_PORT: int = 5432
|
||||
|
||||
# Redis
|
||||
REDIS_HOST: str = "redis"
|
||||
REDIS_PORT: int = 6379
|
||||
|
||||
# Steve
|
||||
STEVE_BASE_URL: str = "https://s1.byunc.com/steve"
|
||||
STEVE_API_USER: str = "admin"
|
||||
STEVE_API_PASSWORD: str = "changeme"
|
||||
|
||||
# 토스페이먼츠
|
||||
TOSS_CLIENT_KEY: str = ""
|
||||
TOSS_SECRET_KEY: str = ""
|
||||
|
||||
# 요금 (원/kWh)
|
||||
ELECTRICITY_RATE: int = 120
|
||||
SERVICE_MARGIN: int = 50
|
||||
|
||||
# JWT
|
||||
JWT_SECRET: str = "change-me"
|
||||
JWT_ALGORITHM: str = "HS256"
|
||||
JWT_EXPIRE_MINUTES: int = 1440
|
||||
|
||||
# 서버
|
||||
DEBUG: bool = True
|
||||
|
||||
@property
|
||||
def database_url(self) -> str:
|
||||
return (
|
||||
f"postgresql+asyncpg://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}"
|
||||
f"@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
||||
)
|
||||
|
||||
@property
|
||||
def database_url_sync(self) -> str:
|
||||
return (
|
||||
f"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}"
|
||||
f"@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
||||
)
|
||||
|
||||
@property
|
||||
def redis_url(self) -> str:
|
||||
return f"redis://{self.REDIS_HOST}:{self.REDIS_PORT}/0"
|
||||
|
||||
@property
|
||||
def total_rate(self) -> int:
|
||||
"""총 충전 단가 (원/kWh)"""
|
||||
return self.ELECTRICITY_RATE + self.SERVICE_MARGIN
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
env_file_encoding = "utf-8"
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
Reference in New Issue
Block a user