Automated Action 48f0debd7b Implement user authentication flow with FastAPI
- Set up FastAPI application with SQLite database
- Create User model with email and password fields
- Implement JWT token-based authentication
- Add user registration and login endpoints
- Create protected user profile endpoints
- Configure Alembic for database migrations
- Add password hashing with bcrypt
- Include CORS middleware and health endpoint
- Update README with setup and usage instructions

Environment variables required:
- SECRET_KEY: JWT secret key for token signing
2025-06-27 09:18:50 +00:00

22 lines
512 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
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)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()