Automated Action 8575427c43 Implement user authentication flow
- Setup project structure with FastAPI
- Create user models with SQLAlchemy
- Implement JWT authentication
- Create auth endpoints (register, login, me)
- Add health endpoint
- Generate Alembic migrations
- Update documentation

Generated with BackendIM... (backend.im)
2025-05-12 17:00:50 +00:00

28 lines
670 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
# Ensure db directory exists
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()