Przejdź do głównej zawartości

Wzorce rozwoju serverless

Przyspiesz rozwój serverless z Cursor i Claude Code. Te wzorce obejmują AWS Lambda, Vercel, Cloudflare Workers, architektury sterowane zdarzeniami i najlepsze praktyki cloud-native zoptymalizowane pod asystowany przez AI development.

  1. Otwórz Cursor w swoim workspace
  2. Uruchom tryb Agent (Cmd/Ctrl + I)
  3. Prompt: “Create serverless project with:
    • AWS Lambda functions
    • API Gateway integration
    • DynamoDB tables
    • CloudFormation/SAM
    • TypeScript support
    • Local development setup”
  4. Agent konfiguruje kompletne środowisko serverless
// Prompt dla funkcji Lambda:
"Create Lambda function for image processing:
- S3 trigger for uploads
- Image resizing with Sharp
- Multiple output formats
- Error handling and retries
- CloudWatch logging
- X-Ray tracing"
// Wygenerowana struktura:
functions/
imageProcessor/
handler.ts
config.yml
tests/
shared/
utils/
types/

Optymalizacja cold startów

// Prompt: "Optimize Lambda cold starts:
// - Minimize bundle size
// - Lazy loading
// - Connection pooling
// - Provisioned concurrency"

Obsługa błędów

// Prompt: "Add Lambda error handling:
// - Dead letter queues
// - Retry policies
// - Circuit breakers
// - Graceful degradation"
// Prompt dla Vercel Edge function:
"Create Vercel Edge function for:
- Geographic routing
- A/B testing
- Request transformation
- Authentication at edge
- Response caching
- Streaming responses"
// Trasa API Next.js:
"Create API route with:
- Request validation
- Database connection
- Rate limiting
- CORS handling
- Error responses"
// Prompt dla Cloudflare Worker:
"Create Worker for API gateway:
- Request routing
- Authentication
- Rate limiting with Durable Objects
- Cache API usage
- KV storage integration
- R2 bucket access"
  1. Zaprojektuj stan: “Create Durable Object for WebSocket rooms”
  2. Zaimplementuj logikę: “Add room management and messaging”
  3. Strategia skalowania: “Configure geographic distribution”
  4. Monitoruj: “Add analytics and debugging”
// Prompt dla architektury sterowanej zdarzeniami:
"Design event processing system with:
- SNS/SQS integration
- Event routing rules
- Schema validation
- Dead letter handling
- Event replay capability
- Monitoring and alerting"

Event Sourcing

Zaimplementuj z pomocą AI:

  • Projektowanie event store
  • Wersjonowanie zdarzeń
  • Budowanie projekcji
  • Tworzenie snapshotów
  • Logika powtarzania zdarzeń
// Prompt projektowania DynamoDB:
"Design DynamoDB schema for:
- Single table design
- GSI optimization
- Composite keys
- Transactions
- Streams processing
- Auto-scaling"
-- Aurora Serverless:
"Configure Aurora Serverless v2:
- Connection pooling
- Data API usage
- Scaling policies
- Backup strategies"