MCPcopy Create free account
hub / github.com/0010aor/FlashNotes / Settings

Class Settings

backend/src/core/config.py:25–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24
25class Settings(BaseSettings):
26 model_config = SettingsConfigDict(
27 env_file=".env", env_ignore_empty=True, extra="ignore"
28 )
29 API_V1_STR: str = "/api/v1"
30 SECRET_KEY: str = secrets.token_urlsafe(32)
31 # 60 minutes * 24 hours * 8 days = 8 days
32 ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
33 DOMAIN: str = "localhost"
34 ENVIRONMENT: Literal["local", "staging", "production"] = "local"
35
36 BACKEND_CORS_ORIGINS: Annotated[
37 list[AnyUrl] | str, BeforeValidator(parse_cors)
38 ] = []
39
40 PROJECT_NAME: str
41 EMAIL_TEST_USER: str = "test@example.com"
42
43 POSTGRES_SERVER: str
44 POSTGRES_PORT: int = 5432
45 POSTGRES_USER: str
46 POSTGRES_PASSWORD: str
47 POSTGRES_DB: str = ""
48
49 @computed_field # type: ignore[misc]
50 @property
51 def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn:
52 return MultiHostUrl.build(
53 scheme="postgresql+psycopg",
54 username=self.POSTGRES_USER,
55 password=self.POSTGRES_PASSWORD,
56 host=self.POSTGRES_SERVER,
57 port=self.POSTGRES_PORT,
58 path=self.POSTGRES_DB,
59 )
60
61 FIRST_SUPERUSER: str
62 FIRST_SUPERUSER_PASSWORD: str
63 USERS_OPEN_REGISTRATION: bool = False
64
65 AI_API_KEY: str | None = None
66 AI_MODEL: str | None = None
67 AI_MAX_USAGE_QUOTA: int = 30
68 AI_QUOTA_TIME_RANGE_DAYS: int = 1
69
70 COLLECTION_GENERATION_PROMPT: str | None = None
71 CARD_GENERATION_PROMPT: str | None = None
72
73 @computed_field # type: ignore[prop-decorator]
74 @property
75 def ai_models_enabled(self) -> bool:
76 return bool(self.AI_API_KEY and self.AI_MODEL)
77
78 def _check_default_secret(self, var_name: str, value: str | None) -> None:
79 if value == "changethis":
80 message = (
81 f'The value of {var_name} is "changethis", '
82 "for security, please change it, at least for deployments."

Callers 1

config.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected