-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
51 lines (36 loc) · 1.39 KB
/
config.py
File metadata and controls
51 lines (36 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
from functools import lru_cache
class BaseConfig:
DATABASE_URI: str = os.getenv("DATABASE_URI")
DATABASE_USER: str = os.getenv("DATABASE_USER")
JWT_SALT: str = os.getenv("JWT_SALT")
ACTIVITY_LOGGER_URL = os.getenv("ACTIVITY_LOGGER_URL")
MAIL_USERNAME : str = os.getenv("MAIL_USERNAME")
MAIL_PASSWORD : str = os.getenv("MAIL_PASSWORD")
# Admin databases
ADMIN_PSQL_HOST: str = os.getenv("ADMIN_PSQL_HOST")
ADMIN_PSQL_PORT: int = os.getenv("ADMIN_PSQL_PORT")
ADMIN_PSQL_USER : str = os.getenv("ADMIN_PSQL_USER")
ADMIN_PSQL_PASSWORD : str = os.getenv("ADMIN_PSQL_PASSWORD")
ADMIN_MYSQL_USER : str = os.getenv("ADMIN_MYSQL_USER")
ADMIN_MYSQL_PASSWORD : str = os.getenv("ADMIN_MYSQL_PASSWORD")
ADMIN_MYSQL_HOST: str = os.getenv("ADMIN_MYSQL_HOST")
ADMIN_MYSQL_PORT: int = os.getenv("ADMIN_MYSQL_PORT")
class DevelopmentConfig(BaseConfig):
pass
class ProductionConfig(BaseConfig):
pass
class TestingConfig(BaseConfig):
TEST_DATABASE_URI = os.getenv("TEST_DATABASE_URI")
FASTAPI_ENV = "testing"
@lru_cache()
def get_settings():
config_cls_dict = {
"development": DevelopmentConfig,
"production": ProductionConfig,
"testing": TestingConfig
}
config_name = os.environ.get("FASTAPI_ENV", "development")
config_cls = config_cls_dict[config_name]
return config_cls()
settings = get_settings()