feat: return user data when marking episode as watched
This commit is contained in:
@@ -8,9 +8,9 @@ import {
|
||||
EpisodeNumberSchema,
|
||||
ErrorResponse,
|
||||
ErrorResponseSchema,
|
||||
SuccessResponse,
|
||||
SuccessResponseSchema,
|
||||
} from "~/types/schema";
|
||||
import { User } from "~/types/user";
|
||||
|
||||
import { markEpisodeAsWatched } from "./anilist";
|
||||
|
||||
@@ -39,7 +39,7 @@ const route = createRoute({
|
||||
200: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: SuccessResponseSchema(),
|
||||
schema: SuccessResponseSchema(User),
|
||||
},
|
||||
},
|
||||
description: "Returns whether the episode was marked as watched",
|
||||
@@ -78,7 +78,7 @@ app.openapi(route, async (c) => {
|
||||
await c.req.json<typeof MarkEpisodeAsWatchedRequest._type>();
|
||||
|
||||
try {
|
||||
await markEpisodeAsWatched(
|
||||
const user = await markEpisodeAsWatched(
|
||||
aniListToken,
|
||||
aniListId,
|
||||
episodeNumber,
|
||||
@@ -93,13 +93,18 @@ app.openapi(route, async (c) => {
|
||||
"COMPLETED",
|
||||
);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
console.error("Failed to mark episode as watched - user not found?");
|
||||
return c.json(ErrorResponse, { status: 500 });
|
||||
}
|
||||
|
||||
return c.json({ success: true, result: user }, 200);
|
||||
} catch (error) {
|
||||
console.error("Failed to mark episode as watched");
|
||||
console.error(error);
|
||||
return c.json(ErrorResponse, { status: 500 });
|
||||
}
|
||||
|
||||
return c.json(SuccessResponse, 200);
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user