Automated Action d84f05f712 Create FastAPI REST API service with user management
- Set up FastAPI application with proper project structure
- Configure SQLite database with SQLAlchemy ORM
- Implement user model with CRUD operations
- Add Alembic for database migrations
- Create comprehensive API endpoints for user management
- Configure CORS middleware for cross-origin requests
- Add health check endpoint and service information
- Set up Ruff for code linting and formatting
- Update README with complete documentation

Co-Authored-By: BackendIM <noreply@backendim.com>
2025-06-18 07:32:46 +00:00

50 lines
1.1 KiB
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.v1.api import api_router
from app.db.base import Base
from app.db.session import engine
# Create tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="REST API Service",
description="A REST API service built with FastAPI",
version="1.0.0",
openapi_url="/openapi.json",
docs_url="/docs",
redoc_url="/redoc",
)
# CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include API router
app.include_router(api_router, prefix="/api/v1")
@app.get("/")
async def root():
return {
"title": "REST API Service",
"description": "A REST API service built with FastAPI",
"version": "1.0.0",
"documentation": "/docs",
"health_check": "/health"
}
@app.get("/health")
async def health_check():
return {
"status": "healthy",
"service": "REST API Service",
"version": "1.0.0"
}