aboutsummaryrefslogtreecommitdiff
path: root/apps/web/src/app
diff options
context:
space:
mode:
authoryxshv <[email protected]>2024-04-15 01:57:39 +0530
committeryxshv <[email protected]>2024-04-15 01:57:39 +0530
commit0ce7c916ffcbf6515c3da521775c72861bddd53c (patch)
treea23c4b9b8bce9b7124c8574ee6f60709b522c6ae /apps/web/src/app
parentspace expand layout (diff)
downloadsupermemory-0ce7c916ffcbf6515c3da521775c72861bddd53c.tar.xz
supermemory-0ce7c916ffcbf6515c3da521775c72861bddd53c.zip
add profile and fix drawer scroll
Diffstat (limited to 'apps/web/src/app')
-rw-r--r--apps/web/src/app/api/chat/route.ts72
-rw-r--r--apps/web/src/app/api/getCount/route.ts4
-rw-r--r--apps/web/src/app/globals.css11
-rw-r--r--apps/web/src/app/layout.tsx1
4 files changed, 51 insertions, 37 deletions
diff --git a/apps/web/src/app/api/chat/route.ts b/apps/web/src/app/api/chat/route.ts
index c78c9484..374f39cd 100644
--- a/apps/web/src/app/api/chat/route.ts
+++ b/apps/web/src/app/api/chat/route.ts
@@ -69,39 +69,43 @@ export async function POST(req: NextRequest) {
});
}
- const resp = await fetch(
- `https://cf-ai-backend.dhravya.workers.dev/chat?q=${query}&user=${session.user.email ?? session.user.name}&sourcesOnly=${sourcesOnly}&spaces=${spaces}`,
- {
- headers: {
- "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY,
- },
- method: "POST",
- body: JSON.stringify({
- chatHistory: chatHistory.chatHistory ?? [],
- }),
- },
- );
-
- console.log("sourcesOnly", sourcesOnly);
-
- if (sourcesOnly == "true") {
- const data = await resp.json();
- console.log("data", data);
- return new Response(JSON.stringify(data), { status: 200 });
- }
-
- if (resp.status !== 200 || !resp.ok) {
- const errorData = await resp.json();
- console.log(errorData);
- return new Response(
- JSON.stringify({ message: "Error in CF function", error: errorData }),
- { status: resp.status },
- );
- }
-
- // Stream the response back to the client
- const { readable, writable } = new TransformStream();
- resp && resp.body!.pipeTo(writable);
+ try {
+ const resp = await fetch(
+ `https://cf-ai-backend.dhravya.workers.dev/chat?q=${query}&user=${session.user.email ?? session.user.name}&sourcesOnly=${sourcesOnly}&spaces=${spaces}`,
+ {
+ headers: {
+ "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY,
+ },
+ method: "POST",
+ body: JSON.stringify({
+ chatHistory: chatHistory.chatHistory ?? [],
+ }),
+ },
+ );
+
+ console.log("sourcesOnly", sourcesOnly);
+
+ if (sourcesOnly == "true") {
+ const data = await resp.json();
+ console.log("data", data);
+ return new Response(JSON.stringify(data), { status: 200 });
+ }
+
+ if (resp.status !== 200 || !resp.ok) {
+ const errorData = await resp.json();
+ console.log(errorData);
+ return new Response(
+ JSON.stringify({ message: "Error in CF function", error: errorData }),
+ { status: resp.status },
+ );
+ }
+
+ // Stream the response back to the client
+ const { readable, writable } = new TransformStream();
+ resp && resp.body!.pipeTo(writable);
+
+ return new Response(readable, { status: 200 });
+ } catch {
+ }
- return new Response(readable, { status: 200 });
}
diff --git a/apps/web/src/app/api/getCount/route.ts b/apps/web/src/app/api/getCount/route.ts
index 3238e58a..9fe54f78 100644
--- a/apps/web/src/app/api/getCount/route.ts
+++ b/apps/web/src/app/api/getCount/route.ts
@@ -1,5 +1,5 @@
import { db } from "@/server/db";
-import { and, eq, sql } from "drizzle-orm";
+import { and, eq, ne, sql } from "drizzle-orm";
import { sessions, storedContent, users } from "@/server/db/schema";
import { type NextRequest, NextResponse } from "next/server";
@@ -66,7 +66,7 @@ export async function GET(req: NextRequest) {
.where(
and(
eq(storedContent.user, session.user.id),
- eq(storedContent.type, "page"),
+ ne(storedContent.type, "twitter-bookmark"),
),
);
diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css
index e4523452..9a543be6 100644
--- a/apps/web/src/app/globals.css
+++ b/apps/web/src/app/globals.css
@@ -57,6 +57,17 @@ body {
padding-bottom: 15dvh;
}
+.bottom-padding {
+ bottom: 20vh;
+ bottom: 20dvh;
+}
+
+@media (min-width: 768px) {
+ .bottom-padding {
+ bottom: 0;
+ }
+}
+
.chat-answer code {
@apply bg-rgray-3 text-wrap rounded-md border border-rgray-5 p-1 text-sm text-rgray-11;
}
diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx
index e5a447dc..b57c3d9c 100644
--- a/apps/web/src/app/layout.tsx
+++ b/apps/web/src/app/layout.tsx
@@ -2,7 +2,6 @@ import type { Metadata } from "next";
import { Roboto, Inter } from "next/font/google";
import "./globals.css";
-const roboto = Roboto({ weight: ["300", "400", "500"], subsets: ["latin"] });
const inter = Inter({ weight: ["300", "400", "500"], subsets: ["latin"] });
export const metadata: Metadata = {