import http from 'k6/http'
import { check, sleep } from 'k6'

export const options = {
  vus: 5,
  duration: '30s',
  thresholds: {
    http_req_failed: ['rate<0.01'],
    http_req_duration: ['p(95)<800'], // p95 < 800ms for these lightweight endpoints
  },
}

const BASE_URL = __ENV.BASE_URL || 'http://localhost:8000'

export default function () {
  // Health
  const health = http.get(`${BASE_URL}/health`)
  check(health, {
    'health status 200': (r) => r.status === 200,
  })

  // Public: auctions feed (anonymous)
  const feed = http.get(`${BASE_URL}/api/v1/auctions/feed?source=external&limit=20&offset=0&sort_by=score`)
  check(feed, {
    'feed status 200': (r) => r.status === 200,
  })

  // Public: trending TLDs
  const trending = http.get(`${BASE_URL}/api/v1/tld-prices/trending`)
  check(trending, {
    'trending status 200': (r) => r.status === 200,
  })

  sleep(1)
}


