59 lines
1.1 KiB
Python
59 lines
1.1 KiB
Python
from pydantic import BaseSettings
|
|
|
|
|
|
class Base(BaseSettings):
|
|
pass
|
|
|
|
|
|
class AuthConf(Base):
|
|
AUTH_ACCESS_TOKEN_EXPIRE_MINUTES: int
|
|
AUTH_REFRESH_TOKEN_EXPIRE_MINUTES: int
|
|
AUTH_ALGORITHM: str
|
|
AUTH_SECRET_KEY: str
|
|
|
|
|
|
class MongoConf(Base):
|
|
MONGO_URL: str
|
|
MONGO_DB: str
|
|
AUTH_DB: str
|
|
PROD_MONGO_URL: str
|
|
PROD_MONGO_DB: str
|
|
PROD_AUTH_DB: str
|
|
|
|
|
|
class Conf(AuthConf, MongoConf):
|
|
app_name: str = "Awesome API"
|
|
admin_email: str
|
|
items_per_user: int = 50
|
|
TEST_VAR: int
|
|
IS_PROD: bool = False
|
|
PREFIX_API_URL: str
|
|
FILE_SYSTEM_BASE_URL: str
|
|
LINKER_URL: str
|
|
|
|
|
|
|
|
class Config:
|
|
env_file = '.env'
|
|
|
|
def getMongoUrl(
|
|
self): return conf.IS_PROD and conf.PROD_MONGO_URL or conf.MONGO_URL
|
|
|
|
def getMongoDb(
|
|
self):
|
|
return conf.IS_PROD and self.PROD_MONGO_DB or self.MONGO_DB
|
|
|
|
def getAuthDb(
|
|
self):
|
|
return conf.IS_PROD and self.PROD_AUTH_DB or self.AUTH_DB
|
|
|
|
def getLinkerDb(self):
|
|
return 'linker'
|
|
|
|
|
|
def getNamespaceApi(prefix):
|
|
return f"{conf.PREFIX_API_URL}/{prefix}"
|
|
|
|
|
|
conf = Conf(admin_email='ar.azizan@gmail.com')
|