feat: set up mock data to be used to generate baseline profiles
This commit is contained in:
@@ -38,6 +38,27 @@ app.openapi(route, async (c) => {
|
||||
const page = Number(c.req.query("page") ?? 1);
|
||||
const limit = Number(c.req.query("limit") ?? 10);
|
||||
|
||||
// Check if we should use mock data
|
||||
const { useMockData } = await import("~/libs/useMockData");
|
||||
if (useMockData()) {
|
||||
const { mockSearchResults } = await import("~/mocks/mockData");
|
||||
|
||||
// Paginate mock results
|
||||
const startIndex = (page - 1) * limit;
|
||||
const endIndex = startIndex + limit;
|
||||
const paginatedResults = mockSearchResults.slice(startIndex, endIndex);
|
||||
const hasNextPage = endIndex < mockSearchResults.length;
|
||||
|
||||
return c.json(
|
||||
{
|
||||
success: true,
|
||||
results: paginatedResults,
|
||||
hasNextPage,
|
||||
},
|
||||
200,
|
||||
);
|
||||
}
|
||||
|
||||
const { result: response, errorOccurred } = await fetchFromMultipleSources([
|
||||
() => fetchSearchResultsFromAnilist(query, page, limit),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user