mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-05 15:30:40 +00:00
fix: stuff
This commit is contained in:
parent
626ca898e4
commit
e30e9f4e0b
6 changed files with 7727 additions and 15754 deletions
|
|
@ -2,6 +2,7 @@ import { type NextRequest } from "next/server";
|
|||
import { addFromAPIType } from "@repo/shared-types";
|
||||
import { ensureAuth } from "../ensureAuth";
|
||||
import { createMemoryFromAPI } from "./helper";
|
||||
import { getRawTweet } from "@repo/shared-types/utils";
|
||||
|
||||
export const runtime = "edge";
|
||||
|
||||
|
|
@ -22,14 +23,36 @@ export async function POST(req: NextRequest) {
|
|||
body = await req.json();
|
||||
} catch (e) {
|
||||
const error = (e as Error).message;
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
message: "A JSON was not sent to the API. " + error,
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
},
|
||||
);
|
||||
|
||||
console.log(error);
|
||||
|
||||
const tryJson = getRawTweet(await req.text());
|
||||
console.log(tryJson);
|
||||
|
||||
if (tryJson) {
|
||||
try {
|
||||
body = JSON.parse(tryJson);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
message: "Raw found but not json?" + error,
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
message: "Raw not found & not json." + error,
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const validated = addFromAPIType.safeParse(body);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue