53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""
|
||
服务端配置文件
|
||
使用环境变量或 .env 文件加载敏感配置
|
||
"""
|
||
import os
|
||
from pydantic_settings import BaseSettings
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
# -------------------------------------------------------
|
||
# 应用
|
||
# -------------------------------------------------------
|
||
APP_NAME: str = "Boss直聘投递服务端"
|
||
APP_VERSION: str = "1.0.0"
|
||
DEBUG: bool = False
|
||
|
||
# -------------------------------------------------------
|
||
# 数据库(MySQL)
|
||
# -------------------------------------------------------
|
||
DB_HOST: str = "127.0.0.1"
|
||
DB_PORT: int = 3306
|
||
DB_USER: str = "root"
|
||
DB_PASSWORD: str = ""
|
||
DB_NAME: str = "jianli_boss"
|
||
|
||
@property
|
||
def DATABASE_URL(self) -> str:
|
||
return (
|
||
f"mysql+pymysql://{self.DB_USER}:{self.DB_PASSWORD}"
|
||
f"@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
|
||
f"?charset=utf8mb4"
|
||
)
|
||
|
||
# -------------------------------------------------------
|
||
# JWT 认证
|
||
# -------------------------------------------------------
|
||
SECRET_KEY: str = "change-this-to-a-random-secret-key-in-production"
|
||
JWT_ALGORITHM: str = "HS256"
|
||
# Token 有效期(天)
|
||
ACCESS_TOKEN_EXPIRE_DAYS: int = 30
|
||
|
||
# -------------------------------------------------------
|
||
# CORS(允许客户端 Web 面板访问)
|
||
# -------------------------------------------------------
|
||
CORS_ORIGINS: list[str] = ["*"]
|
||
|
||
class Config:
|
||
env_file = ".env"
|
||
env_file_encoding = "utf-8"
|
||
|
||
|
||
settings = Settings()
|