Spaces:
Running
Running
File size: 906 Bytes
97ec6f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import { error, json } from '@sveltejs/kit';
// import { env } from '$env/dynamic/private'
import type { CommunityCard } from '$lib/type';
import { REACTION_EMOJIS } from "$lib/utils";
/** @type {import('./$types').RequestHandler} */
export async function GET() {
const hasError = false
const cards: CommunityCard[] = Array.from({ length: 50 }, (_, i) => ({
reactions: REACTION_EMOJIS.sort(() => Math.random() - Math.random()).slice(0,
Math.floor(Math.random() * REACTION_EMOJIS.length)
).map((emoji) => ({
emoji,
users: Array.from({ length: Math.floor(Math.random() * 10) }, (_, i) => i.toString()),
})),
id: i.toString(),
model_name: "CommunityCard",
prompt: "What is your favorite color?",
image: "https://picsum.photos/seed/" + i + "/500/500",
}))
if (hasError) {
return error(500, 'Internal Server Error')
}
return json(cards)
}
|