mirror of
https://github.com/duthaho/claudekit.git
synced 2026-06-10 12:14:57 +03:00
3.3 KiB
3.3 KiB
name, description
| name | description |
|---|---|
| backend-frameworks | Use when building REST APIs or web servers with FastAPI, Django, NestJS, or Express — including routing, middleware, dependency injection, Pydantic models, serializers, controllers, services, guards, pipes, app.get, app.post, APIRouter, class-based views, or framework-specific patterns. |
Backend Frameworks
When to Use
- Building REST APIs with FastAPI, Django REST Framework, NestJS, or Express
- Configuring middleware, routing, authentication, or request validation
- Setting up dependency injection, services, or module structure
- Integrating with databases via ORMs (SQLAlchemy, Django ORM, TypeORM, Prisma)
- WebSocket servers, microservices, or GraphQL resolvers
When NOT to Use
- Frontend development — use
frontend - Database-specific queries without framework context — use
databases - API design/documentation — use
openapi
Quick Reference
| Framework | Reference | Language | Key features |
|---|---|---|---|
| FastAPI | references/fastapi.md |
Python | Pydantic, async, APIRouter, Depends(), OpenAPI auto-docs |
| Django | references/django.md |
Python | ORM, admin, DRF serializers, class-based views, migrations |
| NestJS | references/nestjs.md |
TypeScript | Modules, DI, guards, pipes, interceptors, Prisma/TypeORM |
| Express | references/express.md |
TypeScript | Middleware, Router, error handling, helmet, rate limiting |
Best Practices
- Use validation models for all request/response data. Pydantic (FastAPI), class-validator DTOs (NestJS), Zod (Express), serializers (Django).
- Separate business logic from routes/controllers. Route handlers handle HTTP; services handle domain logic.
- Organize routes by resource and version. APIRouter (FastAPI), module structure (NestJS), Router (Express), URL conf (Django).
- Return proper HTTP status codes. 201 for creation, 204 for deletion, 202 for accepted-but-not-done, 409 for conflicts.
- Use async all the way down. Never mix sync blocking calls in async routes (especially FastAPI).
- Configure settings from environment variables. pydantic-settings (FastAPI), django-environ (Django), dotenv (Express/NestJS).
- Use
select_related/prefetch_relatedfor every query touching relations (Django). - Use
transaction.atomic()for multi-step writes (Django).
Common Pitfalls
- Blocking I/O in async routes.
requests.get(),time.sleep()inasync defroutes starves the event loop (FastAPI). - Missing response_model / leaking internal fields (FastAPI).
- N+1 queries from missing eager loading (Django
select_related, NestJS relations). - Circular imports/dependencies. Use
forwardRef()(NestJS), restructure modules (Django/FastAPI). - Forgetting
asyncHandler— unhandled promise rejections crash the process (Express). - Error handler not registered last (Express).
- Putting business logic in controllers (NestJS).
- Not using
whitelist: trueon ValidationPipe (NestJS).
Related Skills
databases— Database queries, schema design, migrationsopenapi— API specification and documentationerror-handling— Exception handling and API error responsesauthentication— Auth flows for web applications