diff options
| author | Dhravya <[email protected]> | 2024-02-26 17:53:38 -0700 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-02-26 17:53:38 -0700 |
| commit | eba818ffb4ca84f24f4d29924533bc2c098c88ce (patch) | |
| tree | 542bbc30559a93bc4569fcc103e9cc2fdc20e50c /apps/web/src | |
| parent | chaos (diff) | |
| download | supermemory-eba818ffb4ca84f24f4d29924533bc2c098c88ce.tar.xz supermemory-eba818ffb4ca84f24f4d29924533bc2c098c88ce.zip | |
EVERYTHING WORKING PERFECTLY
Diffstat (limited to 'apps/web/src')
21 files changed, 621 insertions, 91 deletions
diff --git a/apps/web/src/app/MessagePoster.tsx b/apps/web/src/app/MessagePoster.tsx new file mode 100644 index 00000000..ad7d450d --- /dev/null +++ b/apps/web/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/web/src/app/api/auth/[...nextauth]/route.ts b/apps/web/src/app/api/[...nextauth]/route.ts index db7d1fb8..db7d1fb8 100644 --- a/apps/web/src/app/api/auth/[...nextauth]/route.ts +++ b/apps/web/src/app/api/[...nextauth]/route.ts diff --git a/apps/web/src/app/api/hello/route.ts b/apps/web/src/app/api/hello/route.ts new file mode 100644 index 00000000..705b3cb8 --- /dev/null +++ b/apps/web/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/web/src/app/api/store/route.ts b/apps/web/src/app/api/store/route.ts index 0d1c38ff..c1c3eee1 100644 --- a/apps/web/src/app/api/store/route.ts +++ b/apps/web/src/app/api/store/route.ts @@ -7,15 +7,18 @@ 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 token = req.cookies.get("next-auth.session-token")?.value ?? req.cookies.get("authjs.session-token")?.value ?? req.headers.get("Authorization")?.replace("Bearer ", ""); + + console.log(token ? token : 'token not found lol') + console.log(process.env.DATABASE) const session = await db.select().from(sessions).where(eq(sessions.sessionToken, token!)) - .leftJoin(users, eq(sessions.userId, users.id)) + .leftJoin(users, eq(sessions.userId, users.id)).limit(1) 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 }); + return NextResponse.json({ message: "OK", data: session }, { status: 200 }); } catch (error) { return NextResponse.json({ message: "Error", error }, { status: 500 }); } diff --git a/apps/web/src/app/favicon.ico b/apps/web/src/app/favicon.ico Binary files differnew file mode 100644 index 00000000..718d6fea --- /dev/null +++ b/apps/web/src/app/favicon.ico diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css new file mode 100644 index 00000000..875c01e8 --- /dev/null +++ b/apps/web/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/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx index 9d62d395..3314e478 100644 --- a/apps/web/src/app/layout.tsx +++ b/apps/web/src/app/layout.tsx @@ -1,28 +1,22 @@ -import '@/styles/globals.css'; +import type { Metadata } from "next"; +import { Inter } from "next/font/google"; +import "./globals.css"; -import { Inter } from 'next/font/google'; +const inter = Inter({ subsets: ["latin"] }); -const inter = Inter({ - subsets: ['latin'], - variable: '--font-sans', -}); - -export const metadata = { - title: 'Create T3 App', - description: 'Generated by create-t3-app', - icons: [{ rel: 'icon', url: '/favicon.ico' }], +export const metadata: Metadata = { + title: "Create Next App", + description: "Generated by create next app", }; -export const runtime = 'edge'; - export default function RootLayout({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { +}>) { return ( <html lang="en"> - <body className={`font-sans ${inter.variable}`}>{children}</body> + <body className={inter.className}>{children}</body> </html> ); } diff --git a/apps/web/src/app/not-found.tsx b/apps/web/src/app/not-found.tsx new file mode 100644 index 00000000..3409889a --- /dev/null +++ b/apps/web/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/web/src/app/page.tsx b/apps/web/src/app/page.tsx index 3b9e44c4..f6c8981f 100644 --- a/apps/web/src/app/page.tsx +++ b/apps/web/src/app/page.tsx @@ -1,12 +1,15 @@ -import { cookies } from 'next/headers'; -import MessagePoster from '../../../anycontext-front/src/app/MessagePoster'; +import Image from "next/image"; +import MessagePoster from "./MessagePoster"; +import { cookies } from "next/headers"; +import { Component } from "@/components/component"; export const runtime = 'edge'; -export default function HomePage() { +export default function Home() { return ( <main> <MessagePoster jwt={cookies().get('next-auth.session-token')?.value!} /> + <Component/> </main> ); } diff --git a/apps/web/src/components/component.tsx b/apps/web/src/components/component.tsx new file mode 100644 index 00000000..3edb2049 --- /dev/null +++ b/apps/web/src/components/component.tsx @@ -0,0 +1,192 @@ +/** + * This code was generated by v0 by Vercel. + * @see https://v0.dev/t/pva6O4OIeZq + */ +import { Input } from "@/components/ui/input" +import { AvatarImage, AvatarFallback, Avatar } from "@/components/ui/avatar" +import { Button } from "@/components/ui/button" +import { Badge } from "@/components/ui/badge" +import { CardContent, CardFooter, Card } from "@/components/ui/card" + +export function Component() { + return ( + <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> + <header className="flex justify-between items-center py-6"> + <div className="flex items-center space-x-4"> + <FlagIcon className="h-8 w-8 text-blue-500" /> + <h1 className="text-3xl font-bold text-gray-900">zenfetch</h1> + </div> + <div className="flex items-center space-x-4"> + <Input className="w-72" placeholder="Search..." /> + <Avatar> + <AvatarImage alt="User avatar" src="/placeholder.svg?height=32&width=32" /> + <AvatarFallback>U</AvatarFallback> + </Avatar> + <Button className="whitespace-nowrap" variant="outline"> + Chat with AI + </Button> + </div> + </header> + <nav className="flex space-x-2 my-4"> + <Badge variant="secondary">Technology (2)</Badge> + <Badge variant="secondary">Business & Finance (1)</Badge> + <Badge variant="secondary">Education & Career (1)</Badge> + </nav> + <main className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> + <Card className="w-full"> + <img + alt="Hard drive" + className="w-full h-48 object-cover" + height="200" + src="/placeholder.svg" + style={{ + aspectRatio: "300/200", + objectFit: "cover", + }} + width="300" + /> + <CardContent> + <h3 className="text-lg font-semibold">I'd like to sell you a hard drive.</h3> + <p className="text-sm text-gray-600">SUBSTACK.COM</p> + <p className="text-sm"> + Zenfetch is a proposed tool aimed to help knowledge workers retain and leverage the knowledge. + </p> + </CardContent> + <CardFooter className="flex justify-between"> + <Button variant="ghost">Read More</Button> + </CardFooter> + </Card> + <Card className="w-full"> + <img + alt="AI Prompting" + className="w-full h-48 object-cover" + height="200" + src="/placeholder.svg" + style={{ + aspectRatio: "300/200", + objectFit: "cover", + }} + width="300" + /> + <CardContent> + <h3 className="text-lg font-semibold">A guide to prompting AI (for what it is worth)</h3> + <p className="text-sm text-gray-600">ONEUSEFULTHING.ORG</p> + <p className="text-sm">Summary is still generating. Try refreshing the page in a few seconds.</p> + </CardContent> + <CardFooter className="flex justify-between"> + <Button variant="ghost">Read More</Button> + </CardFooter> + </Card> + <Card className="w-full"> + <img + alt="Unlocking Creativity" + className="w-full h-48 object-cover" + height="200" + src="/placeholder.svg" + style={{ + aspectRatio: "300/200", + objectFit: "cover", + }} + width="300" + /> + <CardContent> + <h3 className="text-lg font-semibold">Pixel Perfect: How AI Unlocks Creativity</h3> + <p className="text-sm text-gray-600">DIGITALNATIVE.TECH</p> + <p className="text-sm">Summary is still generating. Try refreshing the page in a few seconds.</p> + </CardContent> + <CardFooter className="flex justify-between"> + <Button variant="ghost">Read More</Button> + </CardFooter> + </Card> + <Card className="w-full"> + <img + alt="Tolerance for Fiction" + className="w-full h-48 object-cover" + height="200" + src="/placeholder.svg" + style={{ + aspectRatio: "300/200", + objectFit: "cover", + }} + width="300" + /> + <CardContent> + <h3 className="text-lg font-semibold"> + Our Declining Tolerance for Fiction & Wild Concepts Likely To Become + </h3> + <p className="text-sm text-gray-600">ARXIV.ORG</p> + <p className="text-sm">Summary is still generating. Try refreshing the page in a few seconds.</p> + </CardContent> + <CardFooter className="flex justify-between"> + <Button variant="ghost">Read More</Button> + </CardFooter> + </Card> + <Card className="w-full"> + <img + alt="Graph of Thoughts" + className="w-full h-48 object-cover" + height="200" + src="/placeholder.svg" + style={{ + aspectRatio: "300/200", + objectFit: "cover", + }} + width="300" + /> + <CardContent> + <h3 className="text-lg font-semibold"> + Graph of Thoughts: Solving Elaborate Problems with Large Language Models + </h3> + <p className="text-sm text-gray-600">ARXIV.ORG</p> + <p className="text-sm">Summary is still generating. Try refreshing the page in a few seconds.</p> + </CardContent> + <CardFooter className="flex justify-between"> + <Button variant="ghost">Read More</Button> + </CardFooter> + </Card> + <Card className="w-full"> + <img + alt="Lacking creativity" + className="w-full h-48 object-cover" + height="200" + src="/placeholder.svg" + style={{ + aspectRatio: "300/200", + objectFit: "cover", + }} + width="300" + /> + <CardContent> + <h3 className="text-lg font-semibold">You're not lacking creativity, you're overwhelmed</h3> + <p className="text-sm text-gray-600">ARXIV.ORG</p> + <p className="text-sm">Summary is still generating. Try refreshing the page in a few seconds.</p> + </CardContent> + <CardFooter className="flex justify-between"> + <Button variant="ghost">Read More</Button> + </CardFooter> + </Card> + </main> + </div> + ) +} + + +function FlagIcon(props: React.SVGProps<SVGSVGElement>) { + return ( + <svg + {...props} + xmlns="http://www.w3.org/2000/svg" + width="24" + height="24" + viewBox="0 0 24 24" + fill="none" + stroke="currentColor" + strokeWidth="2" + strokeLinecap="round" + strokeLinejoin="round" + > + <path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z" /> + <line x1="4" x2="4" y1="22" y2="15" /> + </svg> + ) +} diff --git a/apps/web/src/components/ui/avatar.tsx b/apps/web/src/components/ui/avatar.tsx new file mode 100644 index 00000000..fb190df3 --- /dev/null +++ b/apps/web/src/components/ui/avatar.tsx @@ -0,0 +1,50 @@ +"use client" + +import * as React from "react" +import * as AvatarPrimitive from "@radix-ui/react-avatar" + +import { cn } from "@/lib/utils" + +const Avatar = React.forwardRef< + React.ElementRef<typeof AvatarPrimitive.Root>, + React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> +>(({ className, ...props }, ref) => ( + <AvatarPrimitive.Root + ref={ref} + className={cn( + "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", + className + )} + {...props} + /> +)) +Avatar.displayName = AvatarPrimitive.Root.displayName + +const AvatarImage = React.forwardRef< + React.ElementRef<typeof AvatarPrimitive.Image>, + React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> +>(({ className, ...props }, ref) => ( + <AvatarPrimitive.Image + ref={ref} + className={cn("aspect-square h-full w-full", className)} + {...props} + /> +)) +AvatarImage.displayName = AvatarPrimitive.Image.displayName + +const AvatarFallback = React.forwardRef< + React.ElementRef<typeof AvatarPrimitive.Fallback>, + React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> +>(({ className, ...props }, ref) => ( + <AvatarPrimitive.Fallback + ref={ref} + className={cn( + "flex h-full w-full items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800", + className + )} + {...props} + /> +)) +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName + +export { Avatar, AvatarImage, AvatarFallback } diff --git a/apps/web/src/components/ui/badge.tsx b/apps/web/src/components/ui/badge.tsx new file mode 100644 index 00000000..1e21383f --- /dev/null +++ b/apps/web/src/components/ui/badge.tsx @@ -0,0 +1,36 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border border-gray-200 px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-gray-950 focus:ring-offset-2 dark:border-gray-800 dark:focus:ring-gray-300", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes<HTMLDivElement>, + VariantProps<typeof badgeVariants> {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( + <div className={cn(badgeVariants({ variant }), className)} {...props} /> + ) +} + +export { Badge, badgeVariants } diff --git a/apps/web/src/components/ui/button.tsx b/apps/web/src/components/ui/button.tsx new file mode 100644 index 00000000..b67d2657 --- /dev/null +++ b/apps/web/src/components/ui/button.tsx @@ -0,0 +1,56 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const buttonVariants = cva( + "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-gray-950 dark:focus-visible:ring-gray-300", + { + variants: { + variant: { + default: "bg-primary text-primary-foreground hover:bg-primary/90", + destructive: + "bg-destructive text-destructive-foreground hover:bg-destructive/90", + outline: + "border border-input bg-background hover:bg-accent hover:text-accent-foreground", + secondary: + "bg-secondary text-secondary-foreground hover:bg-secondary/80", + ghost: "hover:bg-accent hover:text-accent-foreground", + link: "text-primary underline-offset-4 hover:underline", + }, + size: { + default: "h-10 px-4 py-2", + sm: "h-9 rounded-md px-3", + lg: "h-11 rounded-md px-8", + icon: "h-10 w-10", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) + +export interface ButtonProps + extends React.ButtonHTMLAttributes<HTMLButtonElement>, + VariantProps<typeof buttonVariants> { + asChild?: boolean +} + +const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( + ({ className, variant, size, asChild = false, ...props }, ref) => { + const Comp = asChild ? Slot : "button" + return ( + <button + className={cn(buttonVariants({ variant, size, className }))} + ref={ref} + {...props} + /> + ) + } +) +Button.displayName = "Button" + +export { Button, buttonVariants } diff --git a/apps/web/src/components/ui/card.tsx b/apps/web/src/components/ui/card.tsx new file mode 100644 index 00000000..65119a16 --- /dev/null +++ b/apps/web/src/components/ui/card.tsx @@ -0,0 +1,79 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +const Card = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes<HTMLDivElement> +>(({ className, ...props }, ref) => ( + <div + ref={ref} + className={cn( + "rounded-lg border border-gray-200 bg-white text-gray-950 shadow-sm dark:border-gray-800 dark:bg-gray-950 dark:text-gray-50", + className + )} + {...props} + /> +)) +Card.displayName = "Card" + +const CardHeader = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes<HTMLDivElement> +>(({ className, ...props }, ref) => ( + <div + ref={ref} + className={cn("flex flex-col space-y-1.5 p-6", className)} + {...props} + /> +)) +CardHeader.displayName = "CardHeader" + +const CardTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes<HTMLHeadingElement> +>(({ className, ...props }, ref) => ( + <h3 + ref={ref} + className={cn( + "text-2xl font-semibold leading-none tracking-tight", + className + )} + {...props} + /> +)) +CardTitle.displayName = "CardTitle" + +const CardDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes<HTMLParagraphElement> +>(({ className, ...props }, ref) => ( + <p + ref={ref} + className={cn("text-sm text-gray-500 dark:text-gray-400", className)} + {...props} + /> +)) +CardDescription.displayName = "CardDescription" + +const CardContent = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes<HTMLDivElement> +>(({ className, ...props }, ref) => ( + <div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> +)) +CardContent.displayName = "CardContent" + +const CardFooter = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes<HTMLDivElement> +>(({ className, ...props }, ref) => ( + <div + ref={ref} + className={cn("flex items-center p-6 pt-0", className)} + {...props} + /> +)) +CardFooter.displayName = "CardFooter" + +export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } diff --git a/apps/web/src/components/ui/input.tsx b/apps/web/src/components/ui/input.tsx new file mode 100644 index 00000000..aae15c80 --- /dev/null +++ b/apps/web/src/components/ui/input.tsx @@ -0,0 +1,25 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +export interface InputProps + extends React.InputHTMLAttributes<HTMLInputElement> {} + +const Input = React.forwardRef<HTMLInputElement, InputProps>( + ({ className, type, ...props }, ref) => { + return ( + <input + type={type} + className={cn( + "flex h-10 w-full rounded-md border border-gray-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-800 dark:bg-gray-950 dark:ring-offset-gray-950 dark:placeholder:text-gray-400 dark:focus-visible:ring-gray-300", + className + )} + ref={ref} + {...props} + /> + ) + } +) +Input.displayName = "Input" + +export { Input } diff --git a/apps/web/src/env.js b/apps/web/src/env.js index eea6b505..8ab01a59 100644 --- a/apps/web/src/env.js +++ b/apps/web/src/env.js @@ -1,25 +1,20 @@ import { createEnv } from "@t3-oss/env-nextjs"; import { z } from "zod"; + export const env = createEnv({ /** * Specify your server-side environment variables schema here. This way you can ensure the app * isn't built with invalid env vars. */ server: { - DATABASE_URL: z - .string() - .refine( - (str) => !str.includes("YOUR_MYSQL_URL_HERE"), - "You forgot to change the default URL" - ), NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), NEXTAUTH_SECRET: process.env.NODE_ENV === "production" ? z.string() - : z.string().optional(), + : z.string(), NEXTAUTH_URL: z.preprocess( // This makes Vercel deployments not fail if you don't set NEXTAUTH_URL // Since NextAuth.js automatically uses the VERCEL_URL if present. diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts new file mode 100644 index 00000000..d084ccad --- /dev/null +++ b/apps/web/src/lib/utils.ts @@ -0,0 +1,6 @@ +import { type ClassValue, clsx } from "clsx" +import { twMerge } from "tailwind-merge" + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)) +} diff --git a/apps/web/src/server/auth.ts b/apps/web/src/server/auth.ts index 3b8d749e..2a6f61b9 100644 --- a/apps/web/src/server/auth.ts +++ b/apps/web/src/server/auth.ts @@ -1,18 +1,17 @@ import { env } from "@/env"; -import { DrizzleAdapter } from "@auth/drizzle-adapter"; -import NextAuth, { DefaultSession } from "next-auth"; -import { Adapter } from "next-auth/adapters"; +import NextAuth from "next-auth"; import Google from "next-auth/providers/google"; +import { DrizzleAdapter } from "@auth/drizzle-adapter" import { db } from "./db"; -import { createTable } from "./db/schema"; export const { handlers: { GET, POST }, auth, } = NextAuth({ secret: env.NEXTAUTH_SECRET, + trustHost: true, callbacks: { - session: ({session, token}) => ({ + session: ({ session, token }) => ({ ...session, user: { ...session.user, @@ -21,17 +20,11 @@ export const { }, }) }, - adapter: DrizzleAdapter(db, createTable) as Adapter, + adapter: DrizzleAdapter(db), providers: [ Google({ clientId: env.GOOGLE_CLIENT_ID, clientSecret: env.GOOGLE_CLIENT_SECRET, - authorization: { - params: { - prompt: "consent", - response_type: "code", - }, - }, }), ], }); diff --git a/apps/web/src/server/db/index.ts b/apps/web/src/server/db/index.ts index bdfa2968..6eea27b2 100644 --- a/apps/web/src/server/db/index.ts +++ b/apps/web/src/server/db/index.ts @@ -2,7 +2,9 @@ import { drizzle } from 'drizzle-orm/d1'; import * as schema from "./schema"; +console.log(process.env.DATABASE); + export const db = drizzle( - process.env!.D1Database! as unknown as D1Database, - { schema } + process.env.DATABASE, + { schema, logger: true } ); diff --git a/apps/web/src/server/db/schema.ts b/apps/web/src/server/db/schema.ts index 7de02f15..888445ae 100644 --- a/apps/web/src/server/db/schema.ts +++ b/apps/web/src/server/db/schema.ts @@ -14,50 +14,27 @@ import { type AdapterAccount } from "next-auth/adapters"; * * @see https://orm.drizzle.team/docs/goodies#multi-project-schema */ -export const createTable = sqliteTableCreator((name) => `anycontext_${name}`); - -export const posts = createTable( - "post", - { - id: int("id", { mode: "number" }).primaryKey({ autoIncrement: true }), - name: text("name", { length: 256 }), - createdById: text("createdById", { length: 255 }) - .notNull() - .references(() => users.id), - createdAt: int("created_at", { mode: "timestamp" }) - .default(sql`CURRENT_TIMESTAMP`) - .notNull(), - updatedAt: int("updatedAt", { mode: "timestamp" }), - }, - (example) => ({ - createdByIdIdx: index("createdById_idx").on(example.createdById), - nameIndex: index("name_idx").on(example.name), - }) -); +export const createTable = sqliteTableCreator((name) => `${name}`); export const users = createTable("user", { id: text("id", { length: 255 }).notNull().primaryKey(), name: text("name", { length: 255 }), email: text("email", { length: 255 }).notNull(), - emailVerified: int("emailVerified", { - mode: "timestamp", - }).default(sql`CURRENT_TIMESTAMP`), + emailVerified: int("emailVerified", { mode: "timestamp" }).default(sql`CURRENT_TIMESTAMP`), image: text("image", { length: 255 }), }); export const usersRelations = relations(users, ({ many }) => ({ accounts: many(accounts), + sessions: many(sessions), })); export const accounts = createTable( "account", { - userId: text("userId", { length: 255 }) - .notNull() - .references(() => users.id), - type: text("type", { length: 255 }) - .$type<AdapterAccount["type"]>() - .notNull(), + id: text("id", { length: 255 }).notNull().primaryKey(), + userId: text("userId", { length: 255 }).notNull().references(() => users.id), + type: text("type", { length: 255 }).notNull(), provider: text("provider", { length: 255 }).notNull(), providerAccountId: text("providerAccountId", { length: 255 }).notNull(), refresh_token: text("refresh_token"), @@ -67,26 +44,20 @@ export const accounts = createTable( scope: text("scope", { length: 255 }), id_token: text("id_token"), session_state: text("session_state", { length: 255 }), + oauth_token_secret: text("oauth_token_secret"), + oauth_token: text("oauth_token"), }, (account) => ({ - compoundKey: primaryKey({ - columns: [account.provider, account.providerAccountId], - }), userIdIdx: index("account_userId_idx").on(account.userId), }) ); -export const accountsRelations = relations(accounts, ({ one }) => ({ - user: one(users, { fields: [accounts.userId], references: [users.id] }), -})); - export const sessions = createTable( "session", { - sessionToken: text("sessionToken", { length: 255 }).notNull().primaryKey(), - userId: text("userId", { length: 255 }) - .notNull() - .references(() => users.id), + id: text("id", { length: 255 }).notNull().primaryKey(), + sessionToken: text("sessionToken", { length: 255 }).notNull(), + userId: text("userId", { length: 255 }).notNull().references(() => users.id), expires: int("expires", { mode: "timestamp" }).notNull(), }, (session) => ({ @@ -94,10 +65,6 @@ export const sessions = createTable( }) ); -export const sessionsRelations = relations(sessions, ({ one }) => ({ - user: one(users, { fields: [sessions.userId], references: [users.id] }), -})); - export const verificationTokens = createTable( "verificationToken", { @@ -108,4 +75,4 @@ export const verificationTokens = createTable( (vt) => ({ compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }), }) -); +);
\ No newline at end of file diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.css deleted file mode 100644 index b5c61c95..00000000 --- a/apps/web/src/styles/globals.css +++ /dev/null @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; |