aboutsummaryrefslogtreecommitdiff
path: root/apps/anycontext-front/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'apps/anycontext-front/src/app')
-rw-r--r--apps/anycontext-front/src/app/MessagePoster.tsx19
-rw-r--r--apps/anycontext-front/src/app/api/[...nextauth]/route.ts2
-rw-r--r--apps/anycontext-front/src/app/api/hello/route.ts22
-rw-r--r--apps/anycontext-front/src/app/api/store/route.ts22
-rw-r--r--apps/anycontext-front/src/app/favicon.icobin0 -> 25931 bytes
-rw-r--r--apps/anycontext-front/src/app/globals.css33
-rw-r--r--apps/anycontext-front/src/app/layout.tsx22
-rw-r--r--apps/anycontext-front/src/app/not-found.tsx58
-rw-r--r--apps/anycontext-front/src/app/page.tsx11
9 files changed, 189 insertions, 0 deletions
diff --git a/apps/anycontext-front/src/app/MessagePoster.tsx b/apps/anycontext-front/src/app/MessagePoster.tsx
new file mode 100644
index 00000000..ad7d450d
--- /dev/null
+++ b/apps/anycontext-front/src/app/MessagePoster.tsx
@@ -0,0 +1,19 @@
+'use client';
+
+import { useEffect } from 'react';
+
+function MessagePoster({ jwt }: { jwt: string }) {
+ useEffect(() => {
+ if (typeof window === 'undefined') return;
+
+ window.postMessage({ jwt }, '*');
+ }, [jwt]);
+
+ return (
+ <button onClick={() => window.postMessage({ jwt }, '*')}>
+ Validate Extension
+ </button>
+ );
+}
+
+export default MessagePoster;
diff --git a/apps/anycontext-front/src/app/api/[...nextauth]/route.ts b/apps/anycontext-front/src/app/api/[...nextauth]/route.ts
new file mode 100644
index 00000000..db7d1fb8
--- /dev/null
+++ b/apps/anycontext-front/src/app/api/[...nextauth]/route.ts
@@ -0,0 +1,2 @@
+export { GET, POST } from "@/server/auth";
+export const runtime = "edge";
diff --git a/apps/anycontext-front/src/app/api/hello/route.ts b/apps/anycontext-front/src/app/api/hello/route.ts
new file mode 100644
index 00000000..705b3cb8
--- /dev/null
+++ b/apps/anycontext-front/src/app/api/hello/route.ts
@@ -0,0 +1,22 @@
+import type { NextRequest } from 'next/server'
+import { getRequestContext } from '@cloudflare/next-on-pages'
+
+export const runtime = 'edge'
+
+export async function GET(request: NextRequest) {
+ let responseText = 'Hello World'
+
+ // In the edge runtime you can use Bindings that are available in your application
+ // (for more details see:
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
+ // - https://developers.cloudflare.com/pages/functions/bindings/
+ // )
+ //
+ // KV Example:
+ // const myKv = getRequestContext().env.MY_KV
+ // await myKv.put('suffix', ' from a KV store!')
+ // const suffix = await myKv.get('suffix')
+ // responseText += suffix
+
+ return new Response(responseText)
+}
diff --git a/apps/anycontext-front/src/app/api/store/route.ts b/apps/anycontext-front/src/app/api/store/route.ts
new file mode 100644
index 00000000..0d1c38ff
--- /dev/null
+++ b/apps/anycontext-front/src/app/api/store/route.ts
@@ -0,0 +1,22 @@
+import { db } from "@/server/db";
+import { eq } from "drizzle-orm";
+import { sessions, users } from "@/server/db/schema";
+import { type NextRequest, NextResponse } from "next/server";
+
+export const runtime = "edge";
+
+export async function GET(req: NextRequest) {
+ try {
+ const token = req.cookies.get("next-auth.session-token")?.value ?? req.headers.get("Authorization")?.replace("Bearer ", "");
+
+ const session = await db.select().from(sessions).where(eq(sessions.sessionToken, token!))
+ .leftJoin(users, eq(sessions.userId, users.id))
+
+ if (!session || session.length === 0) {
+ return NextResponse.json({ message: "Invalid Key, session not found." }, { status: 404 });
+ }
+ return NextResponse.json({ message: "OK", data: session[0] }, { status: 200 });
+ } catch (error) {
+ return NextResponse.json({ message: "Error", error }, { status: 500 });
+ }
+} \ No newline at end of file
diff --git a/apps/anycontext-front/src/app/favicon.ico b/apps/anycontext-front/src/app/favicon.ico
new file mode 100644
index 00000000..718d6fea
--- /dev/null
+++ b/apps/anycontext-front/src/app/favicon.ico
Binary files differ
diff --git a/apps/anycontext-front/src/app/globals.css b/apps/anycontext-front/src/app/globals.css
new file mode 100644
index 00000000..875c01e8
--- /dev/null
+++ b/apps/anycontext-front/src/app/globals.css
@@ -0,0 +1,33 @@
+@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 {
+ color: rgb(var(--foreground-rgb));
+ background: linear-gradient(
+ to bottom,
+ transparent,
+ rgb(var(--background-end-rgb))
+ )
+ rgb(var(--background-start-rgb));
+}
+
+@layer utilities {
+ .text-balance {
+ text-wrap: balance;
+ }
+}
diff --git a/apps/anycontext-front/src/app/layout.tsx b/apps/anycontext-front/src/app/layout.tsx
new file mode 100644
index 00000000..3314e478
--- /dev/null
+++ b/apps/anycontext-front/src/app/layout.tsx
@@ -0,0 +1,22 @@
+import type { Metadata } from "next";
+import { Inter } from "next/font/google";
+import "./globals.css";
+
+const inter = Inter({ subsets: ["latin"] });
+
+export const metadata: Metadata = {
+ title: "Create Next App",
+ description: "Generated by create next app",
+};
+
+export default function RootLayout({
+ children,
+}: Readonly<{
+ children: React.ReactNode;
+}>) {
+ return (
+ <html lang="en">
+ <body className={inter.className}>{children}</body>
+ </html>
+ );
+}
diff --git a/apps/anycontext-front/src/app/not-found.tsx b/apps/anycontext-front/src/app/not-found.tsx
new file mode 100644
index 00000000..3409889a
--- /dev/null
+++ b/apps/anycontext-front/src/app/not-found.tsx
@@ -0,0 +1,58 @@
+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/anycontext-front/src/app/page.tsx b/apps/anycontext-front/src/app/page.tsx
new file mode 100644
index 00000000..11e75371
--- /dev/null
+++ b/apps/anycontext-front/src/app/page.tsx
@@ -0,0 +1,11 @@
+import Image from "next/image";
+import MessagePoster from "./MessagePoster";
+import { cookies } from "next/headers";
+
+export default function Home() {
+ return (
+ <main>
+ <MessagePoster jwt={cookies().get('next-auth.session-token')?.value!} />
+ </main>
+ );
+}