-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
60 lines (44 loc) · 1.89 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
51
52
53
54
55
56
57
58
59
import os
import pathlib
from urllib.parse import quote
from dotenv import load_dotenv
from motor.motor_asyncio import AsyncIOMotorClient
env_files = [".env.dev", ".env.prod", ".env"]
for env_file in env_files:
if pathlib.Path(env_file).exists():
print(f"Loading env file: {env_file}")
load_dotenv(env_file)
break
else:
print("No .env file found")
MONGO_DB_NAME = os.getenv("MONGO_DB_NAME")
MONGO_DB_USER_NAME = os.getenv("MONGO_DB_USER_NAME")
MONGO_DB_USER_PASSWORD = os.getenv("MONGO_DB_USER_PASSWORD")
if not MONGO_DB_USER_NAME or not MONGO_DB_USER_PASSWORD:
raise Exception("MONGO_DB_USER_NAME and MONGO_DB_USER_PASSWORD must be set")
MONGO_DB_USER_NAME = quote(MONGO_DB_USER_NAME, safe="")
MONGO_DB_USER_PASSWORD = quote(MONGO_DB_USER_PASSWORD, safe="")
MONGO_DB_APP_NAME = os.getenv("MONGO_DB_APP_NAME")
MONGO_DB_URI = os.getenv("MONGO_DB_URI")
MONGO_DB_URI = MONGO_DB_URI.format(
username=MONGO_DB_USER_NAME,
password=MONGO_DB_USER_PASSWORD,
app_name=MONGO_DB_APP_NAME,
)
MONGO_DB_CLIENT = AsyncIOMotorClient(MONGO_DB_URI)
DATABASE = MONGO_DB_CLIENT[MONGO_DB_NAME]
# JWT and OTP Configurations
OTP_EXPIRATION_MINUTES = int(os.getenv("OTP_EXPIRATION_MINUTES", "5"))
REFRESH_TOKEN_EXPIRATION_DAYS = int(os.getenv("REFRESH_TOKEN_EXPIRATION_DAYS", "7"))
ACCESS_TOKEN_EXPIRATION_DAYS = int(os.getenv("ACCESS_TOKEN_EXPIRATION_DAYS", "1"))
SECRET_KEY = os.getenv("SECRET_KEY")
ALGORITHM = os.getenv("ALGORITHM")
# Mongo collections configurations
USER_COLLECTION = DATABASE.get_collection("user")
USER_PROFILE_COLLECTION = DATABASE.get_collection("user-profile")
ASTROLOGER_PROFILE_COLLECTION = DATABASE.get_collection("astrologer-profile")
COUNTRIES_COLLECTION = DATABASE.get_collection("countries")
# Geonames Configurations
GEONAMES_USERNAME = os.getenv("GEONAMES_USERNAME")
# Hardcoded OTP : will be removed when Twilio account is upgraded
HARDCODED_OTP = "1234"