
- Added user model and schema definitions - Implemented JWT token authentication - Created endpoints for user registration and login - Added secure password hashing with bcrypt - Set up SQLite database with SQLAlchemy - Created Alembic migrations - Added user management endpoints - Included health check endpoint generated with BackendIM... (backend.im)
31 lines
845 B
Python
31 lines
845 B
Python
from fastapi import FastAPI
|
|
from app.api.v1.routes import router as v1_router
|
|
from app.middlewares.auth import AuthMiddleware
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
app = FastAPI(
|
|
title="User Authentication Service",
|
|
description="A service for user authentication with JWT tokens",
|
|
version="0.1.0",
|
|
)
|
|
|
|
# Add CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # In production, specify the allowed origins
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include API routes
|
|
app.include_router(v1_router, prefix="/api/v1")
|
|
|
|
# Health check endpoint
|
|
@app.get("/health", tags=["Health"])
|
|
async def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |