({
page = 1,
limit = 36,
fetchAll = false,
}: {
page?: number;
limit?: number;
fetchAll?: boolean;
} = {})
| 263 | } |
| 264 | |
| 265 | export async function getMCPs({ |
| 266 | page = 1, |
| 267 | limit = 36, |
| 268 | fetchAll = false, |
| 269 | }: { |
| 270 | page?: number; |
| 271 | limit?: number; |
| 272 | fetchAll?: boolean; |
| 273 | } = {}) { |
| 274 | "use cache"; |
| 275 | cacheLife("hours"); |
| 276 | cacheTag("mcps"); |
| 277 | |
| 278 | const supabase = await createClient(); |
| 279 | |
| 280 | const baseQuery = () => |
| 281 | supabase |
| 282 | .from("mcps") |
| 283 | .select("*") |
| 284 | .eq("active", true) |
| 285 | .order("company_id", { ascending: true, nullsFirst: false }); |
| 286 | |
| 287 | if (fetchAll) { |
| 288 | return fetchAllPages((from, to) => baseQuery().range(from, to), 100); |
| 289 | } |
| 290 | |
| 291 | const { data, error } = await baseQuery() |
| 292 | .limit(limit) |
| 293 | .range((page - 1) * limit, page * limit - 1); |
| 294 | |
| 295 | return { data, error }; |
| 296 | } |
| 297 | |
| 298 | export async function getRecentMCPs({ limit = 8 }: { limit?: number } = {}) { |
| 299 | "use cache"; |
nothing calls this directly
no test coverage detected