mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
feat: add Zero query endpoint and configure ZERO_QUERY_URL
- Create app/api/zero/query/route.ts — resolves named queries to ZQL using handleQueryRequest and mustGetQuery from @rocicorp/zero - Add ZERO_QUERY_URL to both docker-compose files: - dev: http://host.docker.internal:3000 (reaches local Next.js from Docker) - prod: http://frontend:3000 (Docker service networking) Without this endpoint, zero-cache cannot resolve named queries and no data syncs to the client.
This commit is contained in:
parent
4efb4fab4b
commit
8dd539c384
3 changed files with 20 additions and 0 deletions
18
surfsense_web/app/api/zero/query/route.ts
Normal file
18
surfsense_web/app/api/zero/query/route.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { mustGetQuery } from "@rocicorp/zero";
|
||||
import { handleQueryRequest } from "@rocicorp/zero/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import { queries } from "@/zero/queries";
|
||||
import { schema } from "@/zero/schema";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const result = await handleQueryRequest(
|
||||
(name, args) => {
|
||||
const query = mustGetQuery(queries, name);
|
||||
return query.fn({ args, ctx: undefined });
|
||||
},
|
||||
schema,
|
||||
request,
|
||||
);
|
||||
|
||||
return NextResponse.json(result);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue