refactor: cleaned up REST code
Some checks failed
Deploy / Deploy (push) Has been cancelled

also removed any references to Anify
This commit is contained in:
2025-12-06 10:00:26 -05:00
parent ec42ac4026
commit dbc78727bd
74 changed files with 300 additions and 8380 deletions

41
src/graphql.ts Normal file
View File

@@ -0,0 +1,41 @@
import { createSchema, createYoga } from "graphql-yoga";
import { Hono } from "hono";
import { createGraphQLContext } from "./context";
import { resolvers } from "./resolvers";
import { typeDefs } from "./schema";
const schema = createSchema({
typeDefs,
resolvers,
});
const yoga = createYoga({
schema,
graphqlEndpoint: "/graphql",
landingPage: false, // Disable landing page for production
graphiql: {
title: "Aniplay GraphQL API",
},
context: ({ request }) => {
// Extract Hono context from the request
// graphql-yoga passes the raw request, but we need Hono context
// This will be provided when we integrate with Hono
return request as any;
},
});
const app = new Hono<Cloudflare.Env>();
app.all("/", async (c) => {
const graphqlContext = await createGraphQLContext(c);
// Create a custom request object that includes our GraphQL context
const request = c.req.raw.clone();
(request as any).graphqlContext = graphqlContext;
const response = await yoga.fetch(request, graphqlContext);
return response;
});
export default app;