summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2025-10-07 11:04:40 +0300
committerA Farzat <a@farzat.xyz>2025-10-07 11:04:40 +0300
commit0d0b241c3b437736d80b06966c95db1a7cc5db2e (patch)
treee8a35724d7fba7b1d88e0bbae8f9e95259c3a510 /components
parent616725f377dab768620fa59ee70027db0ce39844 (diff)
downloadcsca5028-0d0b241c3b437736d80b06966c95db1a7cc5db2e.tar.gz
csca5028-0d0b241c3b437736d80b06966c95db1a7cc5db2e.zip
Secure mongodb and rabbitmq containers
Diffstat (limited to 'components')
-rw-r--r--components/database.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/components/database.py b/components/database.py
index 72f63e6..f196fe1 100644
--- a/components/database.py
+++ b/components/database.py
@@ -1,12 +1,19 @@
import atexit
+from os import getenv
from typing import Any, Dict
+from dotenv import load_dotenv
from pymongo import MongoClient
from pymongo.database import Database
from pymongo.collection import Collection
from components.subscriptions.typing import SubsDict
from components.users.typing import UserDict
-client: MongoClient[Any] = MongoClient("mongodb://localhost", tz_aware=True)
+load_dotenv('.env')
+
+client: MongoClient[Any] = MongoClient(
+ "mongodb://%s:%s@localhost/admin" % (getenv('MONGO_USER'), getenv('MONGO_PASS')),
+ tz_aware=True,
+)
database: Database[Any] = client.get_database("youtube")
subscriptions: Collection[SubsDict] = database.get_collection("subscriptions")
users: Collection[UserDict] = database.get_collection("users")