Automated Action 1d54b4ec09 Implement user authentication service with FastAPI
- Set up project structure and dependencies
- Create SQLAlchemy database models
- Set up Alembic for database migrations
- Implement user registration and login endpoints
- Add JWT token authentication
- Create middleware for protected routes
- Add health check endpoint
- Update README with documentation

generated with BackendIM... (backend.im)
2025-05-13 16:59:17 +00:00

34 lines
845 B
Python

from fastapi import FastAPI
from app import models
from app.database import engine
from app.routers import auth, users
from app.middleware import jwt_middleware
from pathlib import Path
# Create database tables
models.Base.metadata.create_all(bind=engine)
app = FastAPI(
title="User Authentication Service",
description="A service for user authentication and management",
version="0.1.0",
)
# Add middleware
app.middleware("http")(jwt_middleware.verify_token)
# Include routers
app.include_router(auth.router)
app.include_router(users.router)
@app.get("/health", tags=["Health"])
async def health_check():
"""
Health check endpoint that returns the service status
"""
return {"status": "healthy"}
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)