Skip to content

Commit d27a585

Browse files
committed
generated file: config/settings.py
1 parent a8e0534 commit d27a585

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

config/settings.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from pydantic import BaseSettings, validator
2+
from typing import Optional
3+
import os
4+
import json
5+
import structlog
6+
7+
logger = structlog.get_logger(__name__)
8+
9+
class Settings(BaseSettings):
10+
OPENAI_API_KEY: str
11+
DATABASE_URL: str
12+
JWT_SECRET_KEY: str
13+
LOG_LEVEL: str = "INFO"
14+
SENTRY_DSN: Optional[str] = None
15+
16+
@validator("OPENAI_API_KEY")
17+
def openai_api_key_cannot_be_empty(cls, value):
18+
if not value.strip():
19+
raise ValueError("OPENAI_API_KEY cannot be empty.")
20+
return value
21+
22+
@validator("DATABASE_URL")
23+
def database_url_cannot_be_empty(cls, value):
24+
if not value.strip():
25+
raise ValueError("DATABASE_URL cannot be empty.")
26+
return value
27+
28+
@validator("JWT_SECRET_KEY")
29+
def jwt_secret_key_cannot_be_empty(cls, value):
30+
if not value.strip():
31+
raise ValueError("JWT_SECRET_KEY cannot be empty.")
32+
return value
33+
34+
class Config:
35+
env_file = ".env"
36+
env_file_encoding = "utf-8"
37+
case_sensitive = True
38+
39+
settings = Settings()

0 commit comments

Comments
 (0)