
- Add user authentication with JWT tokens - Implement task CRUD operations with status and priority - Set up SQLite database with SQLAlchemy ORM - Create Alembic migrations for database schema - Add comprehensive API documentation - Include health check endpoint and CORS configuration - Structure codebase with proper separation of concerns
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api import auth, tasks, users
|
|
from app.core.config import settings
|
|
from app.db.session import engine
|
|
from app.db.base import Base
|
|
|
|
app = FastAPI(
|
|
title=settings.app_name,
|
|
version=settings.app_version,
|
|
description="A comprehensive Task Manager API built with FastAPI",
|
|
openapi_url="/openapi.json",
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app.include_router(auth.router, prefix="/auth", tags=["authentication"])
|
|
app.include_router(tasks.router, prefix="/tasks", tags=["tasks"])
|
|
app.include_router(users.router, prefix="/users", tags=["users"])
|
|
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {
|
|
"title": settings.app_name,
|
|
"version": settings.app_version,
|
|
"documentation": "/docs",
|
|
"health_check": "/health",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {
|
|
"status": "healthy",
|
|
"service": settings.app_name,
|
|
"version": settings.app_version,
|
|
}
|