-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
51 lines (36 loc) · 1.34 KB
/
Copy pathconfig.py
File metadata and controls
51 lines (36 loc) · 1.34 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 typing import List
from dotenv import load_dotenv
load_dotenv()
class BaseConfig:
"""Base configuration settings."""
env: str = os.getenv("ENV", "dev")
api: str = "/api"
prefix: str = "/api/v1"
project_name: str = "BoilerPlate"
datetime_format: str = "%Y-%m-%dT%H:%M:%S"
date_format: str = "%Y-%m-%d"
project_root: str = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# AUTH
secret_key: str = os.getenv("SECRET_KEY")
access_token_expire: int = 60 * 24 * 30 # 60 minutes * 24 hours * 30 days = 30 days
backend_cors_origins: List[str] = ["*"]
# DATABASE
engine: str = os.getenv("ENGINE")
user: str = os.getenv("POSTGRES_USER")
password: str = os.getenv("POSTGRES_PASSWORD")
database_name: str = os.getenv("POSTGRES_DB")
host: str = os.getenv("POSTGRES_HOST")
port: str = os.getenv("POSTGRES_PORT")
database_url: str = f"{engine}://{user}:{password}@{host}:{port}/{database_name}"
class TestConfig(BaseConfig):
"""Test configuration settings."""
env: str = "test"
sqlite_file_name = "character.db"
database_url: str = f"sqlite:///{sqlite_file_name}"
def get_settings() -> BaseConfig:
env = os.getenv("ENV", "dev")
if env == "test":
return TestConfig()
return BaseConfig()
settings = get_settings()