python-fastapi-patterns
Build REST APIs with FastAPI patterns
๋ํ ๋ค์์์ ์ฌ์ฉํ ์ ์์ต๋๋ค: 0xDarkMatter
FastAPI is a modern Python web framework for building APIs. This skill provides ready-to-use patterns for dependency injection, validation, middleware, and background tasks. Developers can quickly implement production-ready APIs without searching through documentation.
์คํฌ ZIP ๋ค์ด๋ก๋
Claude์์ ์ ๋ก๋
์ค์ โ ๊ธฐ๋ฅ โ ์คํฌ โ ์คํฌ ์ ๋ก๋๋ก ์ด๋
ํ ๊ธ์ ์ผ๊ณ ์ฌ์ฉ ์์
ํ ์คํธํด ๋ณด๊ธฐ
"python-fastapi-patterns" ์ฌ์ฉ ์ค์ ๋๋ค. Create a FastAPI endpoint that creates a user with email validation
์์ ๊ฒฐ๊ณผ:
- from pydantic import BaseModel, EmailStr, Field
- from fastapi import FastAPI, HTTPException, status
- from datetime import datetime
- ย
- class UserCreate(BaseModel):
- name: str = Field(..., min_length=1, max_length=100)
- email: EmailStr
- age: int = Field(..., ge=18, le=120)
- ย
- class UserResponse(BaseModel):
- id: int
- name: str
- email: EmailStr
- created_at: datetime
- model_config = {"from_attributes": True}
- ย
- @app.post("/users", response_model=UserResponse, status_code=status.HTTP_201_CREATED)
- async def create_user(user: UserCreate):
- # Create user in database
- db_user = await create_user_in_db(user)
- return db_user
๋ณด์ ๊ฐ์ฌ
๋ฎ์ ์ํThis is a documentation and code generation skill containing educational FastAPI patterns. The included bash script generates boilerplate code without executing dangerous operations. No network calls, credential theft, or malicious behavior detected.
๋ฎ์ ์ํ ๋ฌธ์ (2)
์ํ ์์ธ
โก ์คํฌ๋ฆฝํธ ํฌํจ (1)
๐ ํ๊ฒฝ ๋ณ์ (1)
ํ์ง ์ ์
๋ง๋ค ์ ์๋ ๊ฒ
Build REST APIs
Create production-ready REST APIs with FastAPI using proven patterns for routing, validation, and error handling
API scaffolding
Generate CRUD endpoint boilerplate quickly for new resources using the included scaffold script
Learn FastAPI patterns
Understand dependency injection, middleware chains, and async patterns through clear code examples
์ด ํ๋กฌํํธ๋ฅผ ์ฌ์ฉํด ๋ณด์ธ์
Create a FastAPI application with lifespan management for database and cache startup and shutdown
Create a Pydantic model for user registration with email validation, password strength, and confirm password matching
Set up dependency injection for an async database session and a JWT-authenticated current user
Add middleware for request logging, security headers, and rate limiting to a FastAPI app
๋ชจ๋ฒ ์ฌ๋ก
- Use Pydantic models for all request validation and response serialization
- Implement dependency injection for shared resources like databases and caches
- Add middleware early in the stack for CORS and security headers
ํผํ๊ธฐ
- Do not use bare Exception handlers that expose internal errors
- Avoid hardcoding credentials or API keys in source code
- Do not skip validation by using arbitrary JSON response types
์์ฃผ ๋ฌป๋ ์ง๋ฌธ
What Python version is required?
Does this skill handle database connections?
Can I use this with SQLAlchemy?
Is the data I process secure?
How do I debug validation errors?
How is this different from Flask or Django?
๊ฐ๋ฐ์ ์ธ๋ถ ์ ๋ณด
์์ฑ์
0xDarkMatter๋ผ์ด์ ์ค
MIT
๋ฆฌํฌ์งํ ๋ฆฌ
https://github.com/0xDarkMatter/claude-mods/tree/main/skills/python-fastapi-patterns์ฐธ์กฐ
main
ํ์ผ ๊ตฌ์กฐ
๐ assets/
๐ fastapi-template.py
๐ references/
๐ background-tasks.md
๐ validation-serialization.md
๐ scripts/
๐ scaffold-api.sh
๐ SKILL.md