feat: update version to 0.4.3-dev, add file deletion feature, and refactor API structure

This commit is contained in:
Christian Krakau-Louis
2025-04-03 15:55:34 +02:00
parent dc19608ec1
commit 2cafda11dd
17 changed files with 1318 additions and 17 deletions
+36
View File
@@ -0,0 +1,36 @@
"""
Common utilities for API routes
"""
import logging
import os
from sqlalchemy.orm import Session
from fastapi import Depends
from app.database import SessionLocal
from app.config import settings
# Set up logging
logger = logging.getLogger(__name__)
def get_db():
"""Database dependency injection for routes"""
db = SessionLocal()
try:
yield db
finally:
db.close()
def resolve_file_path(file_path: str, subfolder: str = None) -> str:
"""
Resolves a file path to an absolute path.
If the path is not absolute, it will be joined with the workdir path.
Optionally, can include a subfolder like 'processed'.
Returns the absolute file path.
"""
if not os.path.isabs(file_path):
if subfolder:
file_path = os.path.join(settings.workdir, subfolder, file_path)
else:
file_path = os.path.join(settings.workdir, file_path)
return file_path