import { fetchAllData } from '../../services/table-service'

export default defineEventHandler(async (event) => {
  const query = getQuery(event)
  const requestedLimit = Number.parseInt((query.limit as string) ?? '', 10)
  const limit = Number.isFinite(requestedLimit) ? Math.min(Math.max(requestedLimit, 1), 100) : 25

  return await fetchAllData(limit)
})
