mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-05 15:30:40 +00:00
merge conflicts
This commit is contained in:
commit
ffd141ade4
34 changed files with 1012 additions and 256 deletions
10
apps/web/app/api/canvas/route.ts
Normal file
10
apps/web/app/api/canvas/route.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
export function GET(req: Request) {
|
||||
const id = new URL(req.url).searchParams.get("id");
|
||||
return new Response(JSON.stringify(id));
|
||||
}
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = await req.json();
|
||||
const id = new URL(req.url).searchParams.get("id");
|
||||
return new Response(JSON.stringify({ body, id }));
|
||||
}
|
||||
31
apps/web/app/api/canvasai/route.ts
Normal file
31
apps/web/app/api/canvasai/route.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import type { NextRequest } from "next/server";
|
||||
import { ensureAuth } from "../ensureAuth";
|
||||
|
||||
export const runtime = "edge";
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const session = await ensureAuth(request);
|
||||
if (!session) {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
const res: { query: string } = await request.json();
|
||||
|
||||
try {
|
||||
const resp = await fetch(
|
||||
`${process.env.BACKEND_BASE_URL}/api/search?query=${res.query}&user=${session.user.id}`,
|
||||
);
|
||||
if (resp.status !== 200 || !resp.ok) {
|
||||
const errorData = await resp.text();
|
||||
console.log(errorData);
|
||||
return new Response(
|
||||
JSON.stringify({ message: "Error in CF function", error: errorData }),
|
||||
{ status: resp.status },
|
||||
);
|
||||
}
|
||||
return new Response(
|
||||
JSON.stringify({ response: await resp.json(), status: 200 }),
|
||||
);
|
||||
} catch (error) {
|
||||
return new Response(`Error, ${error}`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue