fix: popular category response properly supports pagination
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
||||
|
||||
import { ErrorResponse, SuccessResponseSchema } from "~/types/schema";
|
||||
import {
|
||||
ErrorResponse,
|
||||
PaginatedResponseSchema,
|
||||
SuccessResponseSchema,
|
||||
} from "~/types/schema";
|
||||
import { HomeTitle } from "~/types/title/homeTitle";
|
||||
|
||||
import { fetchPopularTitlesFromAnilist } from "./anilist";
|
||||
import { PopularCategory } from "./enum";
|
||||
|
||||
const BrowsePopularResponse = SuccessResponseSchema(z.array(HomeTitle));
|
||||
const BrowsePopularResponse = PaginatedResponseSchema(HomeTitle);
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -53,7 +57,11 @@ app.openapi(route, async (c) => {
|
||||
return c.json(ErrorResponse, { status: 500 });
|
||||
}
|
||||
|
||||
return c.json({ success: true, result: response });
|
||||
return c.json({
|
||||
success: true,
|
||||
results: response.results,
|
||||
hasNextPage: response.hasNextPage ?? false,
|
||||
});
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user