aboutsummaryrefslogtreecommitdiff
path: root/apps/web/app/api
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-07-04 19:17:51 -0500
committerDhravya <[email protected]>2024-07-04 19:17:51 -0500
commit6ef746da542b8e5da3ef638fb7f46f5aa10a3a02 (patch)
tree07bceba625a40bc0fedd5b8028820ea50032d217 /apps/web/app/api
parentUX: Load while creating memory (diff)
downloadsupermemory-6ef746da542b8e5da3ef638fb7f46f5aa10a3a02.tar.xz
supermemory-6ef746da542b8e5da3ef638fb7f46f5aa10a3a02.zip
revamped extention
Diffstat (limited to 'apps/web/app/api')
-rw-r--r--apps/web/app/api/ensureAuth.ts2
-rw-r--r--apps/web/app/api/store/route.ts16
2 files changed, 10 insertions, 8 deletions
diff --git a/apps/web/app/api/ensureAuth.ts b/apps/web/app/api/ensureAuth.ts
index d2fbac0b..d2c14b3b 100644
--- a/apps/web/app/api/ensureAuth.ts
+++ b/apps/web/app/api/ensureAuth.ts
@@ -22,7 +22,7 @@ export async function ensureAuth(req: NextRequest) {
.innerJoin(users, eq(users.id, sessions.userId))
.where(eq(sessions.sessionToken, token!));
- if (!sessionData || sessionData.length < 0) {
+ if (!sessionData || sessionData.length === 0) {
return undefined;
}
diff --git a/apps/web/app/api/store/route.ts b/apps/web/app/api/store/route.ts
index d9f99277..26636c5c 100644
--- a/apps/web/app/api/store/route.ts
+++ b/apps/web/app/api/store/route.ts
@@ -84,11 +84,7 @@ const createMemoryFromAPI = async (input: {
const error = e as Error;
console.log("Error: ", error.message);
- if (
- error.message.includes(
- "D1_ERROR: UNIQUE constraint failed: storedContent.baseUrl",
- )
- ) {
+ if (error.message.includes("D1_ERROR: UNIQUE constraint failed:")) {
return {
success: false,
data: 0,
@@ -204,9 +200,15 @@ export async function POST(req: NextRequest) {
message: "Failed to save document",
error: result.error,
}),
- { status: 500 },
+ { status: 501 },
);
}
- return new Response("ok", { status: 200 });
+ return new Response(
+ JSON.stringify({
+ message: "Document saved",
+ data: result.data,
+ }),
+ { status: 200 },
+ );
}