diff options
| author | Saatvik Arya <[email protected]> | 2024-07-24 22:14:15 -0700 |
|---|---|---|
| committer | Saatvik Arya <[email protected]> | 2024-07-25 13:08:40 -0700 |
| commit | 04e57ccf80a9fdca045eb5782dc9f520918a4849 (patch) | |
| tree | 5b740f34fbb30895a8a9017ef82427126830b73c /apps/web/app/api | |
| parent | merge oopsies (diff) | |
| download | supermemory-04e57ccf80a9fdca045eb5782dc9f520918a4849.tar.xz supermemory-04e57ccf80a9fdca045eb5782dc9f520918a4849.zip | |
address ts issues
Diffstat (limited to 'apps/web/app/api')
| -rw-r--r-- | apps/web/app/api/store/route.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/web/app/api/store/route.ts b/apps/web/app/api/store/route.ts index f9ab7c01..317b5e83 100644 --- a/apps/web/app/api/store/route.ts +++ b/apps/web/app/api/store/route.ts @@ -52,7 +52,7 @@ const createMemoryFromAPI = async (input: { }; } - let contentId: number | undefined; + let contentId: number; const saveToDbUrl = (input.data.url.split("#supermemory-user-")[0] ?? input.data.url) + @@ -79,7 +79,15 @@ const createMemoryFromAPI = async (input: { }) .returning({ id: storedContent.id }); - contentId = insertResponse[0]?.id; + if (!insertResponse[0]?.id) { + return { + success: false, + data: 0, + error: "Failed to save to database", + }; + } + + contentId = insertResponse[0].id; } catch (e) { const error = e as Error; console.log("Error: ", error.message); @@ -99,14 +107,6 @@ const createMemoryFromAPI = async (input: { }; } - if (!contentId) { - return { - success: false, - data: 0, - error: "Failed to save to database", - }; - } - if (input.data.spaces.length > 0) { // Adding the many-to-many relationship between content and spaces const spaceData = await db |