← スキル一覧に戻る

fastapi-router-creator
by first-fluke
fastapi-router-creatorは、other分野における実用的なスキルです。複雑な課題への対応力を強化し、業務効率と成果の質を改善します。
⭐ 141🍴 21📅 2026年1月23日
SKILL.md
name: fastapi-router-creator description: Guide for creating and organizing FastAPI routes using a file-based routing system or modular router pattern. Helps organize complex API structures.
FastAPI Router Creator
This skill guides the creation of modular, organized FastAPI routers, emphasizing maintainability and scalability.
Routing Strategies
1. Modular Router Pattern (Standard)
The most common and recommended approach for FastAPI.
Structure:
src/api/v1/endpoints/
├── users.py
├── items.py
└── auth.py
Implementation:
src/api/v1/endpoints/users.py:
from fastapi import APIRouter
router = APIRouter()
@router.get("/")
async def get_users():
...
src/api/v1/api.py (Aggregator):
from fastapi import APIRouter
from src.api.v1.endpoints import users, items
api_router = APIRouter()
api_router.include_router(users.router, prefix="/users", tags=["users"])
api_router.include_router(items.router, prefix="/items", tags=["items"])
2. File-Based Routing (fastapi-router)
For a Next.js-like experience where file structure dictates URLs. (Requires fastapi-router library or custom walker).
Structure:
src/app/
├── api/
│ ├── users/
│ │ ├── route.py # Handles /api/users
│ │ └── [id]/
│ │ └── route.py # Handles /api/users/{id}
Best Practices
- Prefixing: Use prefixes at the router include level, not inside every endpoint decorator.
- Tags: Use tags to group endpoints in OpenAPI docs.
- Dependencies: Apply dependencies (like auth) at the router level if they apply to all endpoints in that router.
router = APIRouter(dependencies=[Depends(get_current_active_user)]) - Version: Namespace routers by API version (
v1,v2).
スコア
総合スコア
75/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
✓人気
GitHub Stars 100以上
+5
○最近の活動
3ヶ月以内に更新がある
0/10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です

