diff options
| author | Dhravya <[email protected]> | 2024-07-04 19:17:51 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-07-04 19:17:51 -0500 |
| commit | 6ef746da542b8e5da3ef638fb7f46f5aa10a3a02 (patch) | |
| tree | 07bceba625a40bc0fedd5b8028820ea50032d217 /apps/web/app/api | |
| parent | UX: Load while creating memory (diff) | |
| download | supermemory-6ef746da542b8e5da3ef638fb7f46f5aa10a3a02.tar.xz supermemory-6ef746da542b8e5da3ef638fb7f46f5aa10a3a02.zip | |
revamped extention
Diffstat (limited to 'apps/web/app/api')
| -rw-r--r-- | apps/web/app/api/ensureAuth.ts | 2 | ||||
| -rw-r--r-- | apps/web/app/api/store/route.ts | 16 |
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 }, + ); } |