Skip to content

Commit d798dab

Browse files
authored
Update config.py
1 parent 64e62f9 commit d798dab

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

main/api/mcp/config/config.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import os
2+
from pydantic_settings import BaseSettings
23
from typing import Optional
3-
from pydantic import BaseModel
4-
from slowapi import Limiter
5-
from slowapi.util import get_remote_address
64

7-
class DatabaseConfig:
8-
def __init__(self):
9-
self.url = os.getenv("NEON_DATABASE_URL")
5+
class DatabaseConfig(BaseSettings):
6+
database_url: str = os.getenv("DATABASE_URL", "postgresql://user:password@localhost:5432/neondb")
7+
max_connections: int = 20
8+
min_connections: int = 1
9+
connect_timeout: int = 10
1010

11-
async def query(self, query: str, params: list = None):
12-
# Placeholder for actual database connection logic
13-
pass
11+
class Config:
12+
env_file = ".env"
13+
env_file_encoding = "utf-8"
1414

15-
class ServerConfig(BaseModel):
16-
host: str = "0.0.0.0"
17-
port: int = 8000
18-
ssl_cert_path: Optional[str] = os.getenv("SSL_CERT_PATH")
19-
ssl_key_path: Optional[str] = os.getenv("SSL_KEY_PATH")
20-
google_client_id: str = os.getenv("GOOGLE_CLIENT_ID")
21-
jwt_secret: str = os.getenv("JWT_SECRET")
15+
class APIConfig(BaseSettings):
16+
max_retries: int = 3
17+
rate_limit: int = 100
18+
rate_limit_window: int = 60
19+
api_key: Optional[str] = os.getenv("API_KEY")
20+
api_secret: Optional[str] = os.getenv("API_SECRET")
21+
github_client_id: Optional[str] = os.environ.get("GITHUB_CLIENT_ID")
22+
github_client_secret: Optional[str] = os.environ.get("GITHUB_CLIENT_SECRET")
2223

23-
limiter = Limiter(key_func=get_remote_address)
24-
batch_sync_limiter = limiter.limit("5/minute") # Limit batchSync to 5 requests per minute per IP
24+
class Config:
25+
env_file = ".env"
26+
env_file_encoding = "utf-8"
27+
28+
database_config = DatabaseConfig()
29+
api_config = APIConfig()

0 commit comments

Comments
 (0)