fastapi-development by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill fastapi-development使用 FastAPI 创建快速、现代的 Python API,支持异步/等待操作,自动生成 API 文档,利用 Pydantic 进行类型验证,支持依赖注入、JWT 身份验证,并集成 SQLAlchemy ORM。
最小工作示例:
# main.py
from fastapi import FastAPI, HTTPException, status
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
import logging
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Create FastAPI instance
app = FastAPI(
title="API Service",
description="A modern FastAPI application",
version="1.0.0",
docs_url="/api/docs",
openapi_url="/api/openapi.json"
)
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
// ... (完整实现请参阅参考指南)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/ 目录下的详细实现:
| 指南 | 内容 |
|---|---|
| FastAPI 应用设置 | FastAPI 应用设置 |
| 用于验证的 Pydantic 模型 | 用于验证的 Pydantic 模型 |
| 异步数据库模型与查询 | 异步数据库模型与查询 |
| 安全与 JWT 身份验证 | 安全与 JWT 身份验证 |
| 业务逻辑的服务层 | 业务逻辑的服务层 |
| 包含异步端点的 API 路由 | 包含异步端点的 API 路由 |
每周安装量
237
代码仓库
GitHub 星标数
141
首次出现
2026年1月21日
安全审计
安装于
opencode206
gemini-cli203
codex192
github-copilot180
cursor175
claude-code162
Create fast, modern Python APIs using FastAPI with async/await support, automatic API documentation, type validation using Pydantic, dependency injection, JWT authentication, and SQLAlchemy ORM integration.
Minimal working example:
# main.py
from fastapi import FastAPI, HTTPException, status
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
import logging
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Create FastAPI instance
app = FastAPI(
title="API Service",
description="A modern FastAPI application",
version="1.0.0",
docs_url="/api/docs",
openapi_url="/api/openapi.json"
)
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| FastAPI Application Setup | FastAPI Application Setup |
| Pydantic Models for Validation | Pydantic Models for Validation |
| Async Database Models and Queries | Async Database Models and Queries |
| Security and JWT Authentication | Security and JWT Authentication |
| Service Layer for Business Logic | Service Layer for Business Logic |
| API Routes with Async Endpoints | API Routes with Async Endpoints |
Weekly Installs
237
Repository
GitHub Stars
141
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode206
gemini-cli203
codex192
github-copilot180
cursor175
claude-code162
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
140,500 周安装