aboutsummaryrefslogtreecommitdiff
path: root/apps/web/src/app
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-05-25 18:41:26 -0500
committerDhravya <[email protected]>2024-05-25 18:41:26 -0500
commit075f45986fd4d198292226e64afb71b3515576b4 (patch)
tree5c728356cd0310f1c1c012fd6618c72a836c314b /apps/web/src/app
parentadded social material (diff)
downloadsupermemory-075f45986fd4d198292226e64afb71b3515576b4.tar.xz
supermemory-075f45986fd4d198292226e64afb71b3515576b4.zip
refactored UI, with shared components and UI, better rules and million lint
Diffstat (limited to 'apps/web/src/app')
-rw-r--r--apps/web/src/app/MessagePoster.tsx24
-rw-r--r--apps/web/src/app/api/[...nextauth]/route.ts2
-rw-r--r--apps/web/src/app/api/addTweetsToDb/route.ts91
-rw-r--r--apps/web/src/app/api/ask/route.ts78
-rw-r--r--apps/web/src/app/api/chat/route.ts109
-rw-r--r--apps/web/src/app/api/getCount/route.ts80
-rw-r--r--apps/web/src/app/api/me/route.ts48
-rw-r--r--apps/web/src/app/api/query/route.ts88
-rw-r--r--apps/web/src/app/api/spaces/route.ts72
-rw-r--r--apps/web/src/app/api/store/route.ts165
-rw-r--r--apps/web/src/app/api/vectorizeTweets/route.ts63
-rw-r--r--apps/web/src/app/content.tsx18
-rw-r--r--apps/web/src/app/globals.css140
-rw-r--r--apps/web/src/app/layout.tsx65
-rw-r--r--apps/web/src/app/not-found.tsx58
-rw-r--r--apps/web/src/app/page.tsx97
-rw-r--r--apps/web/src/app/privacy/page.tsx15
-rw-r--r--apps/web/src/app/privacy/privacy.ts49
18 files changed, 0 insertions, 1262 deletions
diff --git a/apps/web/src/app/MessagePoster.tsx b/apps/web/src/app/MessagePoster.tsx
deleted file mode 100644
index 1abad1be..00000000
--- a/apps/web/src/app/MessagePoster.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-"use client";
-
-import { useEffect } from "react";
-
-function MessagePoster({ jwt }: { jwt: string }) {
- useEffect(() => {
- if (typeof window === "undefined") return;
- window.postMessage({ jwt }, "*");
- }, [jwt]);
-
- return (
- <button
- className="p-2"
- onClick={() => {
- if (typeof window === "undefined") return;
- window.postMessage({ jwt }, "*");
- }}
- >
- Extension Auth
- </button>
- );
-}
-
-export default MessagePoster;
diff --git a/apps/web/src/app/api/[...nextauth]/route.ts b/apps/web/src/app/api/[...nextauth]/route.ts
deleted file mode 100644
index db7d1fb8..00000000
--- a/apps/web/src/app/api/[...nextauth]/route.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { GET, POST } from "@/server/auth";
-export const runtime = "edge";
diff --git a/apps/web/src/app/api/addTweetsToDb/route.ts b/apps/web/src/app/api/addTweetsToDb/route.ts
deleted file mode 100644
index 7fe2edba..00000000
--- a/apps/web/src/app/api/addTweetsToDb/route.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-import { db } from "@/server/db";
-import { eq } from "drizzle-orm";
-import { sessions, storedContent, users } from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-
-export const runtime = "edge";
-
-interface TweetData {
- tweetText: string;
- postUrl: string;
- authorName: string;
- handle: string;
- time: string;
- saveToUser: string;
-}
-
-export async function POST(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (!token) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, TOKEN not found." }),
- { status: 404 },
- );
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const user = await db
- .select()
- .from(users)
- .where(eq(users.id, sessionData[0].userId))
- .limit(1);
-
- if (!user || user.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- const session = { session: sessionData[0], user: user[0] };
-
- const data = (await req.json()) as TweetData[];
-
- for (const tweet of data) {
- const { id } = (
- await db
- .insert(storedContent)
- .values({
- content: tweet.tweetText,
- title: "Twitter Bookmark",
- description: "",
- url: tweet.postUrl,
- baseUrl: "https://twitter.com",
- image: "https://supermemory.dhr.wtf/twitter.svg",
- savedAt: new Date(),
- user: session.user.id,
- type: "twitter-bookmark",
- })
- .returning({ id: storedContent.id })
- )[0];
-
- if (!id) {
- return NextResponse.json(
- {
- message: "Error",
- error:
- "Something went wrong when inserting the tweet to storedContent",
- },
- { status: 500 },
- );
- }
- }
-
- return NextResponse.json({ message: "OK", data: "Success" }, { status: 200 });
-}
diff --git a/apps/web/src/app/api/ask/route.ts b/apps/web/src/app/api/ask/route.ts
deleted file mode 100644
index 17b24b3e..00000000
--- a/apps/web/src/app/api/ask/route.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import { db } from "@/server/db";
-import { eq } from "drizzle-orm";
-import { sessions, users } from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-import { env } from "@/env";
-
-export const runtime = "edge";
-
-export async function POST(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (process.env.RATELIMITER) {
- const { success } = await process.env.RATELIMITER.limit({ key: token });
-
- if (!success) {
- return new Response(JSON.stringify({ message: "Rate limit exceeded" }), {
- status: 429,
- });
- }
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const user = await db
- .select()
- .from(users)
- .where(eq(users.id, sessionData[0].userId))
- .limit(1);
-
- if (!user || user.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- const body = (await req.json()) as {
- query: string;
- };
-
- const resp = await fetch(`https://cf-ai-backend.dhravya.workers.dev/ask`, {
- headers: {
- "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY,
- },
- method: "POST",
- body: JSON.stringify({
- query: body.query,
- }),
- });
-
- if (resp.status !== 200 || !resp.ok) {
- const errorData = await resp.json();
- 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 });
-}
diff --git a/apps/web/src/app/api/chat/route.ts b/apps/web/src/app/api/chat/route.ts
deleted file mode 100644
index c815070b..00000000
--- a/apps/web/src/app/api/chat/route.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { db } from "@/server/db";
-import { eq } from "drizzle-orm";
-import { sessions, users } from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-import { env } from "@/env";
-import { ChatHistory } from "../../../../types/memory";
-
-export const runtime = "edge";
-
-export async function POST(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (process.env.RATELIMITER) {
- const { success } = await process.env.RATELIMITER.limit({ key: token });
-
- if (!success) {
- return new Response(JSON.stringify({ message: "Rate limit exceeded" }), {
- status: 429,
- });
- }
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const user = await db
- .select()
- .from(users)
- .where(eq(users.id, sessionData[0].userId))
- .limit(1);
-
- if (!user || user.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- const session = { session: sessionData[0], user: user[0] };
-
- const query = new URL(req.url).searchParams.get("q");
- const spaces = new URL(req.url).searchParams.get("spaces");
-
- const sourcesOnly =
- new URL(req.url).searchParams.get("sourcesOnly") ?? "false";
-
- const chatHistory = (await req.json()) as {
- chatHistory: ChatHistory[];
- };
-
- console.log("CHathistory", chatHistory);
-
- if (!query) {
- return new Response(JSON.stringify({ message: "Invalid query" }), {
- status: 400,
- });
- }
-
- 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 {}
-}
diff --git a/apps/web/src/app/api/getCount/route.ts b/apps/web/src/app/api/getCount/route.ts
deleted file mode 100644
index 9fe54f78..00000000
--- a/apps/web/src/app/api/getCount/route.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-import { db } from "@/server/db";
-import { and, eq, ne, sql } from "drizzle-orm";
-import { sessions, storedContent, users } from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-
-export const runtime = "edge";
-
-export async function GET(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (!token) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const user = await db
- .select()
- .from(users)
- .where(eq(users.id, sessionData[0].userId))
- .limit(1);
-
- if (!user || user.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- const session = { session: sessionData[0], user: user[0] };
-
- const tweetsCount = await db
- .select({
- count: sql<number>`count(*)`.mapWith(Number),
- })
- .from(storedContent)
- .where(
- and(
- eq(storedContent.user, session.user.id),
- eq(storedContent.type, "twitter-bookmark"),
- ),
- );
-
- const pageCount = await db
- .select({
- count: sql<number>`count(*)`.mapWith(Number),
- })
- .from(storedContent)
- .where(
- and(
- eq(storedContent.user, session.user.id),
- ne(storedContent.type, "twitter-bookmark"),
- ),
- );
-
- return NextResponse.json({
- tweetsCount: tweetsCount[0].count,
- tweetsLimit: 1000,
- pageCount: pageCount[0].count,
- pageLimit: 100,
- user: session.user.email,
- });
-}
diff --git a/apps/web/src/app/api/me/route.ts b/apps/web/src/app/api/me/route.ts
deleted file mode 100644
index 6d269872..00000000
--- a/apps/web/src/app/api/me/route.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { db } from "@/server/db";
-import { eq } from "drizzle-orm";
-import { sessions, users } from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-import { env } from "@/env";
-
-export const runtime = "edge";
-
-export async function GET(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- const session = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!session || session.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const user = await db
- .select()
- .from(users)
- .where(eq(users.id, session[0].userId))
- .limit(1);
-
- if (!user || user.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- return new Response(
- JSON.stringify({
- message: "OK",
- data: { session: session[0], user: user[0] },
- }),
- { status: 200 },
- );
-}
diff --git a/apps/web/src/app/api/query/route.ts b/apps/web/src/app/api/query/route.ts
deleted file mode 100644
index 5806841e..00000000
--- a/apps/web/src/app/api/query/route.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { db } from "@/server/db";
-import { eq } from "drizzle-orm";
-import { sessions, users } from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-import { env } from "@/env";
-
-export const runtime = "edge";
-
-export async function GET(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (process.env.RATELIMITER) {
- const { success } = await process.env.RATELIMITER.limit({ key: token });
-
- if (!success) {
- return new Response(JSON.stringify({ message: "Rate limit exceeded" }), {
- status: 429,
- });
- }
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const user = await db
- .select()
- .from(users)
- .where(eq(users.id, sessionData[0].userId))
- .limit(1);
-
- if (!user || user.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- const session = { session: sessionData[0], user: user[0] };
-
- const query = new URL(req.url).searchParams.get("q");
- const sourcesOnly =
- new URL(req.url).searchParams.get("sourcesOnly") ?? "false";
-
- if (!query) {
- return new Response(JSON.stringify({ message: "Invalid query" }), {
- status: 400,
- });
- }
-
- const resp = await fetch(
- `https://cf-ai-backend.dhravya.workers.dev/query?q=${query}&user=${session.user.email ?? session.user.name}&sourcesOnly=${sourcesOnly}`,
- {
- headers: {
- "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY,
- },
- },
- );
-
- console.log(resp.status);
-
- 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 });
-}
diff --git a/apps/web/src/app/api/spaces/route.ts b/apps/web/src/app/api/spaces/route.ts
deleted file mode 100644
index d2685e9f..00000000
--- a/apps/web/src/app/api/spaces/route.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { db } from "@/server/db";
-import { sessions, space, users } from "@/server/db/schema";
-import { eq } from "drizzle-orm";
-import { NextRequest, NextResponse } from "next/server";
-
-export const runtime = "edge";
-
-export async function GET(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (!token) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- if (process.env.RATELIMITER) {
- const { success } = await process.env.RATELIMITER.limit({ key: token });
-
- if (!success) {
- return new Response(JSON.stringify({ message: "Rate limit exceeded" }), {
- status: 429,
- });
- }
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const userData = await db
- .select()
- .from(users)
- .where(eq(users.id, sessionData[0].userId))
- .limit(1);
-
- if (!userData || userData.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- const user = userData[0];
-
- const spaces = await db
- .select()
- .from(space)
- .where(eq(space.user, user.id))
- .all();
-
- return NextResponse.json(
- {
- message: "OK",
- data: spaces,
- },
- { status: 200 },
- );
-}
diff --git a/apps/web/src/app/api/store/route.ts b/apps/web/src/app/api/store/route.ts
deleted file mode 100644
index 457eae2e..00000000
--- a/apps/web/src/app/api/store/route.ts
+++ /dev/null
@@ -1,165 +0,0 @@
-import { db } from "@/server/db";
-import { and, eq, sql, inArray } from "drizzle-orm";
-import {
- contentToSpace,
- sessions,
- storedContent,
- users,
- space,
-} from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-import { env } from "@/env";
-import { getMetaData } from "@/server/helpers";
-
-export const runtime = "edge";
-
-export async function POST(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (!token) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- if (process.env.RATELIMITER) {
- const { success } = await process.env.RATELIMITER.limit({ key: token });
-
- if (!success) {
- return new Response(JSON.stringify({ message: "Rate limit exceeded" }), {
- status: 429,
- });
- }
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const user = await db
- .select()
- .from(users)
- .where(eq(users.id, sessionData[0].userId))
- .limit(1);
-
- if (!user || user.length === 0) {
- return NextResponse.json(
- { message: "Invalid Key, session not found." },
- { status: 404 },
- );
- }
-
- const session = { session: sessionData[0], user: user[0] };
-
- const data = (await req.json()) as {
- pageContent: string;
- url: string;
- spaces?: string[];
- };
-
- const metadata = await getMetaData(data.url);
- let storeToSpaces = data.spaces;
-
- if (!storeToSpaces) {
- storeToSpaces = [];
- }
-
- const count = await db
- .select({
- count: sql<number>`count(*)`.mapWith(Number),
- })
- .from(storedContent)
- .where(
- and(
- eq(storedContent.user, session.user.id),
- eq(storedContent.type, "page"),
- ),
- );
-
- if (count[0].count > 100) {
- return NextResponse.json(
- { message: "Error", error: "Limit exceeded" },
- { status: 499 },
- );
- }
-
- const { id } = (
- await db
- .insert(storedContent)
- .values({
- content: data.pageContent,
- title: metadata.title,
- description: metadata.description,
- url: data.url,
- baseUrl: metadata.baseUrl,
- image: metadata.image,
- savedAt: new Date(),
- user: session.user.id,
- })
- .returning({ id: storedContent.id })
- )[0];
-
- if (!id) {
- return NextResponse.json(
- { message: "Error", error: "Error in CF function" },
- { status: 500 },
- );
- }
-
- if (storeToSpaces.length > 0) {
- const spaceData = await db
- .select()
- .from(space)
- .where(
- and(
- inArray(space.name, storeToSpaces ?? []),
- eq(space.user, session.user.id),
- ),
- )
- .all();
-
- await Promise.all([
- spaceData.forEach(async (space) => {
- await db
- .insert(contentToSpace)
- .values({ contentId: id, spaceId: space.id });
- }),
- ]);
- }
-
- const res = (await Promise.race([
- fetch("https://cf-ai-backend.dhravya.workers.dev/add", {
- method: "POST",
- headers: {
- "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY,
- },
- body: JSON.stringify({ ...data, user: session.user.email }),
- }),
- new Promise((_, reject) =>
- setTimeout(() => reject(new Error("Request timed out")), 40000),
- ),
- ])) as Response;
-
- if (res.status !== 200) {
- console.log(res.status, res.statusText);
- return NextResponse.json(
- { message: "Error", error: "Error in CF function" },
- { status: 500 },
- );
- }
-
- return NextResponse.json({ message: "OK", data: "Success" }, { status: 200 });
-}
diff --git a/apps/web/src/app/api/vectorizeTweets/route.ts b/apps/web/src/app/api/vectorizeTweets/route.ts
deleted file mode 100644
index 63aa38f0..00000000
--- a/apps/web/src/app/api/vectorizeTweets/route.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import { db } from "@/server/db";
-import { eq } from "drizzle-orm";
-import { sessions, storedContent, users } from "@/server/db/schema";
-import { type NextRequest, NextResponse } from "next/server";
-import { env } from "@/env";
-
-export const runtime = "edge";
-
-interface TweetData {
- tweetText: string;
- postUrl: string;
- authorName: string;
- handle: string;
- time: string;
- saveToUser: string;
-}
-
-export async function POST(req: NextRequest) {
- const token =
- req.cookies.get("next-auth.session-token")?.value ??
- req.cookies.get("__Secure-authjs.session-token")?.value ??
- req.cookies.get("authjs.session-token")?.value ??
- req.headers.get("Authorization")?.replace("Bearer ", "");
-
- if (!token) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const sessionData = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!sessionData || sessionData.length === 0) {
- return new Response(
- JSON.stringify({ message: "Invalid Key, session not found." }),
- { status: 404 },
- );
- }
-
- const body = (await req.json()) as TweetData[];
-
- console.log(body);
-
- const resp = await fetch(
- `https://cf-ai-backend.dhravya.workers.dev/batchUploadTweets`,
- {
- headers: {
- "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY,
- },
- method: "POST",
- body: JSON.stringify(body),
- },
- );
-
- return new Response(await resp.text(), {
- status: resp.status,
- headers: resp.headers,
- });
-}
diff --git a/apps/web/src/app/content.tsx b/apps/web/src/app/content.tsx
deleted file mode 100644
index 5a68d902..00000000
--- a/apps/web/src/app/content.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-"use client";
-import SessionProviderWrapper from "@/components/dev/SessionProviderWrapper";
-import Main from "@/components/Main";
-import Sidebar from "@/components/Sidebar/index";
-import { useState } from "react";
-
-export default function Content({ jwt }: { jwt: string }) {
- const [selectedItem, setSelectedItem] = useState<string | null>(null);
-
- return (
- <SessionProviderWrapper>
- <div className="flex w-screen">
- <Sidebar jwt={jwt} selectChange={setSelectedItem} />
- <Main sidebarOpen={selectedItem !== null} />
- </div>
- </SessionProviderWrapper>
- );
-}
diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css
deleted file mode 100644
index bed9278b..00000000
--- a/apps/web/src/app/globals.css
+++ /dev/null
@@ -1,140 +0,0 @@
-@import "@radix-ui/colors/gray";
-@import "@radix-ui/colors/gray-dark";
-
-@tailwind base;
-@tailwind components;
-@tailwind utilities;
-
-:root {
- --foreground-rgb: 0, 0, 0;
- --background-start-rgb: 214, 219, 220;
- --background-end-rgb: 255, 255, 255;
-}
-
-@media (prefers-color-scheme: dark) {
- :root {
- --foreground-rgb: 255, 255, 255;
- --background-start-rgb: 0, 0, 0;
- --background-end-rgb: 0, 0, 0;
- }
-}
-
-body {
- @apply text-rgray-11 max-h-screen overflow-y-hidden bg-white;
- /* color: rgb(var(--foreground-rgb));
- background: linear-gradient(
- to bottom,
- transparent,
- rgb(var(--background-end-rgb))
- )
- rgb(var(--background-start-rgb)); */
-}
-
-[vaul-drawer-wrapper] {
- @apply bg-rgray-2;
-}
-
-@layer utilities {
- .text-balance {
- text-wrap: balance;
- }
-}
-
-.sidebar {
- height: 100vh;
- height: 100dvh;
- max-height: 100vh;
- max-height: 100dvh;
-}
-
-.DrawerContent {
- padding-top: 5vh;
- padding-top: 5dvh;
-}
-
-.main-hidden {
- padding-bottom: 20vh;
- padding-bottom: 15dvh;
-}
-
-.bottom-padding {
- bottom: 20vh;
- bottom: 20dvh;
-}
-
-@media (min-width: 768px) {
- .bottom-padding {
- bottom: 0;
- }
-}
-
-.chat-answer code {
- @apply bg-rgray-3 border-rgray-5 text-rgray-11 text-wrap rounded-md border p-1 text-sm;
-}
-
-.novel-editor pre {
- @apply bg-rgray-3 border-rgray-5 text-rgray-11 my-5 rounded-md border p-4 text-sm;
-}
-
-.chat-answer h1 {
- @apply text-rgray-11 my-5 text-xl font-medium;
-}
-
-.chat-answer a {
- @apply underline underline-offset-1 opacity-90 hover:opacity-100;
-}
-
-.chat-answer img {
- @apply my-5 rounded-md font-medium;
-}
-
-.tippy-box {
- @apply bg-rgray-3 text-rgray-11 border-rgray-5 rounded-md border py-0;
-}
-
-.tippy-content #slash-command {
- @apply text-rgray-11 border-none bg-transparent;
-}
-
-#slash-command button {
- @apply text-rgray-11 py-2;
-}
-
-#slash-command button div:first-child {
- @apply text-rgray-11 bg-rgray-4 border-rgray-5;
-}
-
-#slash-command button.novel-bg-stone-100 {
- @apply bg-rgray-1;
-}
-
-.novel-editor [data-type="taskList"] > li {
- @apply my-0;
-}
-
-.novel-editor input[type="checkbox"] {
- @apply accent-rgray-4 rounded-md;
-
- background: var(--gray-4) !important;
- border: 1px solid var(--gray-10) !important;
-}
-
-.novel-editor .is-empty::before {
- content: "Press '/' for commands" !important;
-}
-
-.novel-editor h1 {
- @apply text-2xl;
-}
-
-.novel-editor h2 {
- @apply text-xl;
-}
-
-.novel-editor h3 {
- @apply text-lg;
-}
-
-.novel-editor .drag-handle {
- @apply hidden;
-}
diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx
deleted file mode 100644
index e96df271..00000000
--- a/apps/web/src/app/layout.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import type { Metadata } from "next";
-import { Roboto, Inter } from "next/font/google";
-import "./globals.css";
-
-const inter = Inter({ weight: ["300", "400", "500"], subsets: ["latin"] });
-
-export const metadata: Metadata = {
- title: "Supermemory - Your second brain",
- description: "Save your memories forever, build your own second brain.",
- openGraph: {
- images: [
- {
- url: "https://supermemory.dhr.wtf/og-image.png",
- width: 1200,
- height: 630,
- },
- ],
- siteName: "Supermemory",
- title: "Supermemory - Your second brain",
- description: "Save your memories forever, build your own second brain.",
- },
- twitter: {
- card: "summary_large_image",
- site: "https://supermemory.dhr.wtf",
- creator: "@dhravyashah",
- description: "Save your memories forever, build your own second brain.",
- images: [
- {
- url: "https://supermemory.dhr.wtf/og-image.png",
- width: 1200,
- height: 630,
- },
- ],
- },
-};
-
-export default function RootLayout({
- children,
-}: Readonly<{
- children: React.ReactNode;
-}>) {
- return (
- <html lang="en" className="dark">
- <head>
- <meta
- name="og:image"
- content="https://supermemory.dhr.wtf/og-image.png"
- />
- <script
- async
- src="https://u.dhr.wtf/script.js"
- data-website-id="731dfc2e-b1c0-4696-a7b3-efd27b19dfdf"
- ></script>
- </head>
- <body className={inter.className}>
- <div
- vaul-drawer-wrapper=""
- className="min-w-screen overflow-x-hidden text-black"
- >
- {children}
- </div>
- </body>
- </html>
- );
-}
diff --git a/apps/web/src/app/not-found.tsx b/apps/web/src/app/not-found.tsx
deleted file mode 100644
index 3409889a..00000000
--- a/apps/web/src/app/not-found.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-export const runtime = "edge";
-
-export default function NotFound() {
- return (
- <>
- <title>404: This page could not be found.</title>
- <div style={styles.error}>
- <div>
- <style
- dangerouslySetInnerHTML={{
- __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`,
- }}
- />
- <h1 className="next-error-h1" style={styles.h1}>
- 404
- </h1>
- <div style={styles.desc}>
- <h2 style={styles.h2}>This page could not be found.</h2>
- </div>
- </div>
- </div>
- </>
- );
-}
-
-const styles = {
- error: {
- fontFamily:
- 'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
- height: "100vh",
- textAlign: "center",
- display: "flex",
- flexDirection: "column",
- alignItems: "center",
- justifyContent: "center",
- },
-
- desc: {
- display: "inline-block",
- },
-
- h1: {
- display: "inline-block",
- margin: "0 20px 0 0",
- padding: "0 23px 0 0",
- fontSize: 24,
- fontWeight: 500,
- verticalAlign: "top",
- lineHeight: "49px",
- },
-
- h2: {
- fontSize: 14,
- fontWeight: 400,
- lineHeight: "49px",
- margin: 0,
- },
-} as const;
diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx
deleted file mode 100644
index 05cd1ab8..00000000
--- a/apps/web/src/app/page.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { db } from "@/server/db";
-import {
- ChachedSpaceContent,
- sessions,
- space,
- storedContent,
- users,
-} from "@/server/db/schema";
-import { and, eq, inArray, not } from "drizzle-orm";
-import { cookies, headers } from "next/headers";
-import { redirect } from "next/navigation";
-import { fetchContentForSpace, fetchFreeMemories } from "@/actions/db";
-import { MemoryProvider } from "@/contexts/MemoryContext";
-import Content from "./content";
-import Main from "@/components/Main";
-import { TailwindIndicator } from "@/components/dev/tailwindindicator";
-
-export const runtime = "edge";
-
-export default async function Home() {
- const token =
- cookies().get("next-auth.session-token")?.value ??
- cookies().get("__Secure-authjs.session-token")?.value ??
- cookies().get("authjs.session-token")?.value ??
- headers().get("Authorization")?.replace("Bearer ", "");
-
- if (!token) {
- return redirect("/api/auth/signin");
- }
-
- const session = await db
- .select()
- .from(sessions)
- .where(eq(sessions.sessionToken, token!));
-
- if (!session || session.length === 0) {
- return redirect("/api/auth/signin");
- }
-
- const [userData] = await db
- .select()
- .from(users)
- .where(eq(users.id, session[0].userId))
- .limit(1);
-
- if (!userData) {
- return redirect("/api/auth/signin");
- }
-
- console.log(storedContent.user.name);
-
- const collectedSpaces = await db
- .select()
- .from(space)
- .where(eq(space.user, userData.id))
- .all();
-
- console.log(collectedSpaces);
-
- // Fetch only first 3 content of each spaces
- let contents: ChachedSpaceContent[] = [];
-
- await Promise.all([
- collectedSpaces.forEach(async (space) => {
- console.log("fetching ");
- const data = (
- (await fetchContentForSpace(space.id, {
- offset: 0,
- limit: 3,
- })) ?? []
- ).map((data) => ({
- ...data,
- space: space.id,
- }));
- contents = [...contents, ...data];
- }),
- ]);
-
- console.log("contents", contents);
-
- // freeMemories
- const freeMemories = await fetchFreeMemories();
- console.log("free", freeMemories);
-
- return (
- <MemoryProvider
- user={userData}
- spaces={collectedSpaces}
- freeMemories={freeMemories}
- cachedMemories={contents}
- >
- <Content jwt={token} />
- <TailwindIndicator />
- {/* <MessagePoster jwt={token} /> */}
- </MemoryProvider>
- );
-}
diff --git a/apps/web/src/app/privacy/page.tsx b/apps/web/src/app/privacy/page.tsx
deleted file mode 100644
index 5e40cbe9..00000000
--- a/apps/web/src/app/privacy/page.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import React from "react";
-import Markdown from "react-markdown";
-import { policy } from "./privacy";
-
-export const runtime = "edge";
-
-function Page() {
- return (
- <div>
- <Markdown>{policy}</Markdown>
- </div>
- );
-}
-
-export default Page;
diff --git a/apps/web/src/app/privacy/privacy.ts b/apps/web/src/app/privacy/privacy.ts
deleted file mode 100644
index 2034f191..00000000
--- a/apps/web/src/app/privacy/privacy.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-export const policy = `
-# Privacy Policy for AnyContext
-
-## Introduction
-
-This Privacy Policy provides detailed information on the handling, storage, and protection of your personal information by AnyContext, a browser extension developed and owned by Dhravya Shah in 2024. The extension is designed to enhance your browsing experience by providing contextual information based on the content of the web pages you visit. This policy outlines the types of data collected by AnyContext, how it is used, and the measures we take to protect your privacy.
-
-## Information Collection
-
-AnyContext collects the following types of information:
-
-1. **Web Browsing Data**: The extension has the capability to see all websites that users visit. However, AnyContext only stores data when the user actively clicks on the extension button while browsing. The browser history is not recorded, ensuring that your browsing activities remain private.
-
-2. **Current Page Data**: Upon activation (click) by the user, AnyContext stores data from the current HTML page. This data is used to provide relevant contextual information based on the content of the page you are viewing.
-
-3. **Personal Information**: When you interact with AnyContext, we may collect personal information including but not limited to your email address, session data, name, and profile picture. This information is collected to improve your user experience and to provide personalized services.
-
-## Data Storage and Security
-
-All collected data is securely stored in a SQLite database hosted on Cloudflare D1. We employ industry-standard security measures to protect your information from unauthorized access, alteration, disclosure, or destruction. Despite our efforts, no method of transmission over the Internet or method of electronic storage is 100% secure. Therefore, while we strive to use commercially acceptable means to protect your personal information, we cannot guarantee its absolute security.
-
-## Use of Information
-
-AnyContext uses the collected information for the following purposes:
-
-- To provide and improve the functionality of the extension.
-- To offer personalized user experiences.
-- To communicate with users regarding updates, support, and promotional offers, if consented.
-- To ensure the security of our services and to detect, prevent, or address technical issues.
-
-## Sharing of Information
-
-AnyContext does not sell, trade, or rent users' personal identification information to others. We may share generic aggregated demographic information not linked to any personal identification information regarding visitors and users with our business partners, trusted affiliates, and advertisers for the purposes outlined above.
-
-## Your Privacy Rights
-
-You have the right to access, update, or delete your personal information that we hold. If you wish to exercise these rights, please contact us at the details provided below.
-
-## Changes to This Privacy Policy
-
-AnyContext reserves the right to update this privacy policy at any time. When we do, we will post a notification on our website and update the date at the top of this page. We encourage users to frequently check this page for any changes to stay informed about how we are protecting the personal information we collect. Your continued use of the service after the posting of changes to this policy will be deemed your acceptance of those changes.
-
-## Contact Us
-
-If you have any questions about this Privacy Policy, the practices of this site, or your dealings with this site, please contact us at:
-
-
-This document was last updated on March 2, 2024.`;