Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions api-server/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fastapi import FastAPI
from contextlib import asynccontextmanager
from dotenv import load_dotenv
from motor.motor_asyncio import AsyncIOMotorClient
from pymongo import AsyncMongoClient
from fastapi.security import OAuth2PasswordBearer

# injecting singletons
Expand Down Expand Up @@ -39,8 +39,13 @@ async def lifespan(app: FastAPI):
logger.info("server starting")

# initializing beanie
client = AsyncIOMotorClient(os.getenv("MONGO_URI"))
db = client[os.getenv("MONGO_DATABASE_NAME")]
client = AsyncMongoClient(os.getenv("MONGO_URI"))

# Get the database name from environment variables.
# If not set, use "default" to avoid errors when accessing client[db_name]
# os.getenv can return None, which is not valid for dictionary-style access
db_name = os.getenv("MONGO_DATABASE_NAME", "exosphere-api-server")
db = client[db_name]
await init_beanie(db, document_models=[User, Project, Satellite])
logger.info("beanie dbs initialized")

Expand Down
2 changes: 1 addition & 1 deletion api-server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"bcrypt>=4.3.0",
"beanie>=1.30.0",
"beanie>=2.0.0",
"docker-image-py>=0.1.13",
"email-validator>=2.2.0",
"fastapi>=0.115.14",
Expand Down
1 change: 0 additions & 1 deletion api-server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
args = parser.parse_args()

load_dotenv()

def serve():
mode = args.mode
if mode == "development":
Expand Down
28 changes: 8 additions & 20 deletions api-server/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.