refactor!: migrate from REST API to GraphQL

- Replace OpenAPI/REST endpoints with a single  route.
- Remove  and Swagger UI configuration.
- Disable OpenAPI schema extensions in Zod types.
- Refactor  to be request-agnostic.
- Update episode URL fetching to return standardized success/failure objects.
- Update project dependencies.
This commit is contained in:
2025-12-01 02:55:20 -05:00
parent ad26cd6da3
commit 495506935e
28 changed files with 1480 additions and 101 deletions

View File

@@ -1,5 +1,4 @@
import { swaggerUI } from "@hono/swagger-ui";
import { OpenAPIHono } from "@hono/zod-openapi";
import { Hono } from "hono";
import { maybeUpdateLastConnectedAt } from "~/controllers/maybeUpdateLastConnectedAt";
import type { QueueName } from "~/libs/tasks/queueName.ts";
@@ -7,67 +6,15 @@ import type { QueueName } from "~/libs/tasks/queueName.ts";
import { onNewEpisode } from "./controllers/internal/new-episode";
import type { QueueBody } from "./libs/tasks/queueTask";
const app = new OpenAPIHono();
const app = new Hono<Cloudflare.Env>();
app.use(maybeUpdateLastConnectedAt);
// GraphQL endpoint replaces all REST routes
app.route(
"/",
await import("~/controllers/health-check").then(
(controller) => controller.default,
),
"/graphql",
await import("~/graphql").then((module) => module.default),
);
app.route(
"/title",
await import("~/controllers/title").then((controller) => controller.default),
);
app.route(
"/episodes",
await import("~/controllers/episodes").then(
(controller) => controller.default,
),
);
app.route(
"/search",
await import("~/controllers/search").then((controller) => controller.default),
);
app.route(
"/watch-status",
await import("~/controllers/watch-status").then(
(controller) => controller.default,
),
);
app.route(
"/token",
await import("~/controllers/token").then((controller) => controller.default),
);
app.route(
"/auth",
await import("~/controllers/auth").then((controller) => controller.default),
);
app.route(
"/popular",
await import("~/controllers/popular").then(
(controller) => controller.default,
),
);
app.route(
"/internal",
await import("~/controllers/internal").then(
(controller) => controller.default,
),
);
// The OpenAPI documentation will be available at /doc
app.doc("/openapi.json", {
openapi: "3.0.0",
info: {
version: "1.0.0",
title: "Aniplay API",
},
});
app.get("/docs", swaggerUI({ url: "/openapi.json" }));
export default {
fetch: app.fetch,