Skip to content

Commit 1143914

Browse files
author
rafsaf
committed
imrpove config setup to work without .env file
Signed-off-by: rafsaf <rafal.safin@rafsaf.pl>
1 parent c8c9ca4 commit 1143914

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

app/core/config.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from functools import lru_cache
1919
from pathlib import Path
2020

21-
from pydantic import AnyHttpUrl, BaseModel, SecretStr, computed_field
21+
from pydantic import AnyHttpUrl, BaseModel, Field, SecretStr, computed_field
2222
from pydantic_settings import BaseSettings, SettingsConfigDict
2323
from sqlalchemy.engine.url import URL
2424

@@ -27,7 +27,7 @@
2727

2828
class Security(BaseModel):
2929
jwt_issuer: str = "my-app"
30-
jwt_secret_key: SecretStr
30+
jwt_secret_key: SecretStr = SecretStr("sk-change-me")
3131
jwt_access_token_expire_secs: int = 24 * 3600 # 1d
3232
refresh_token_expire_secs: int = 28 * 24 * 3600 # 28d
3333
password_bcrypt_rounds: int = 12
@@ -38,15 +38,15 @@ class Security(BaseModel):
3838
class Database(BaseModel):
3939
hostname: str = "postgres"
4040
username: str = "postgres"
41-
password: SecretStr
41+
password: SecretStr = SecretStr("passwd-change-me")
4242
port: int = 5432
4343
db: str = "postgres"
4444

4545

4646
class Settings(BaseSettings):
47-
security: Security
48-
database: Database
49-
log_level: str = "DEBUG"
47+
security: Security = Field(default_factory=Security)
48+
database: Database = Field(default_factory=Database)
49+
log_level: str = "INFO"
5050

5151
@computed_field # type: ignore[prop-decorator]
5252
@property
@@ -78,7 +78,7 @@ def logging_config(log_level: str) -> None:
7878
"disable_existing_loggers": False,
7979
"formatters": {
8080
"verbose": {
81-
"format": "{asctime} {threadName} [{levelname}] {name}: {message}",
81+
"format": "{asctime} [{levelname}] {name}: {message}",
8282
"style": "{",
8383
},
8484
},

0 commit comments

Comments
 (0)