Skip to content

Latest commit

 

History

History
101 lines (79 loc) · 1.86 KB

File metadata and controls

101 lines (79 loc) · 1.86 KB

Development Setup Guide

🔧 Environment Setup

Required Files

# Create .env file in functions directory
echo "OPENAI_API_KEY=your-openai-key-here" > functions/.env

Install Dependencies

npm install
cd functions && npm ci

🚀 Firebase Emulators

Start Emulators

npm run emulators
# or clean start:
npm run emulators:clean

Emulator Ports

🧪 Testing

PowerShell Test (Recommended)

$body = @{
  rawText = "handmade wooden ring box"
  uid = "testuser123" 
  runId = "demo"
  maxRetries = 1
} | ConvertTo-Json

Invoke-RestMethod `
  -Uri "http://localhost:5001/etsy-ai-hacker/us-central1/generateFromDumpCore" `
  -Method Post `
  -ContentType "application/json" `
  -Body $body

Expected Response

{
  "success": true,
  "fields": {
    "title": "Handmade Wooden Ring Box...",
    "tags": ["ring box", "wooden jewelry", ...],
    "description": "Perfect for storing your precious rings..."
  }
}

📊 Monitoring & Logs

Firestore Logs

Debug Output

  • Console logs appear in emulator terminal
  • Error details in firebase-debug.log

🔄 Common Commands

# Clean restart emulators
npm run emulators:clean

# Run tests
npm test

# Check vulnerabilities
npm audit

# Fix vulnerabilities  
npm audit fix

🐛 Troubleshooting

Port Conflicts

If emulators fail to start:

taskkill /f /im node.exe
taskkill /f /im java.exe

Function Not Found

Ensure generateFromDumpCore is properly exported in functions/index.js

OpenAI Errors

Verify OPENAI_API_KEY is set in functions/.env