better backend comms

This commit is contained in:
johba 2025-09-24 09:41:28 +02:00
parent d0e8623cf9
commit 02a057622c
17 changed files with 1054 additions and 134 deletions

View file

@ -1,10 +1,19 @@
import { Hono } from "hono";
import { cors } from "hono/cors";
import { client, graphql } from "ponder";
import { db } from "ponder:api";
import schema from "ponder:schema";
import { Hono } from "hono";
import { client, graphql } from "ponder";
const app = new Hono();
const allowedOrigins = process.env.PONDER_CORS_ORIGINS?.split(",").map((origin) => origin.trim()).filter(Boolean);
app.use("/*", cors({
origin: allowedOrigins?.length ? allowedOrigins : "*",
allowMethods: ["GET", "POST", "OPTIONS"],
allowHeaders: ["Content-Type", "Apollo-Require-Preflight"],
}));
// SQL endpoint
app.use("/sql/*", client({ db, schema }));
@ -12,4 +21,4 @@ app.use("/sql/*", client({ db, schema }));
app.use("/graphql", graphql({ db, schema }));
app.use("/", graphql({ db, schema }));
export default app;
export default app;