forked from teamhide/fastapi-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
50 lines (37 loc) · 1.51 KB
/
config.py
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
import os
from pydantic import BaseSettings
class Config(BaseSettings):
ENV: str = "development"
DEBUG: bool = True
APP_HOST: str = "0.0.0.0"
APP_PORT: int = 8000
WRITER_DB_URL: str = f"mysql+aiomysql://fastapi:fastapi@localhost:3306/fastapi"
READER_DB_URL: str = f"mysql+aiomysql://fastapi:fastapi@localhost:3306/fastapi"
JWT_SECRET_KEY: str = "fastapi"
JWT_ALGORITHM: str = "HS256"
SENTRY_SDN: str = None
CELERY_BROKER_URL: str = "amqp://user:bitnami@localhost:5672/"
CELERY_BACKEND_URL: str = "redis://:password123@localhost:6379/0"
REDIS_HOST: str = "localhost"
REDIS_PORT: int = 6379
class DevelopmentConfig(Config):
WRITER_DB_URL: str = f"mysql+aiomysql://root:fastapi@db:3306/fastapi"
READER_DB_URL: str = f"mysql+aiomysql://root:fastapi@db:3306/fastapi"
REDIS_HOST: str = "redis"
REDIS_PORT: int = 6379
class LocalConfig(Config):
WRITER_DB_URL: str = f"mysql+aiomysql://fastapi:fastapi@localhost:3306/fastapi"
READER_DB_URL: str = f"mysql+aiomysql://fastapi:fastapi@localhost:3306/fastapi"
class ProductionConfig(Config):
DEBUG: str = False
WRITER_DB_URL: str = f"mysql+aiomysql://fastapi:fastapi@localhost:3306/prod"
READER_DB_URL: str = f"mysql+aiomysql://fastapi:fastapi@localhost:3306/prod"
def get_config():
env = os.getenv("ENV", "local")
config_type = {
"dev": DevelopmentConfig(),
"local": LocalConfig(),
"prod": ProductionConfig(),
}
return config_type[env]
config: Config = get_config()