From 1343d16c1a5ba862ff86e60134e5bf598689fdbd Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Fri, 2 Jun 2023 13:28:45 -0400 Subject: [PATCH] Cleanup prisma --- lib/hooks/use-intersection-observer.ts | 43 -------------- lib/prisma.tsx | 11 ---- prisma/schema.prisma | 78 -------------------------- 3 files changed, 132 deletions(-) delete mode 100644 lib/hooks/use-intersection-observer.ts delete mode 100644 lib/prisma.tsx delete mode 100644 prisma/schema.prisma diff --git a/lib/hooks/use-intersection-observer.ts b/lib/hooks/use-intersection-observer.ts deleted file mode 100644 index 4a8d464..0000000 --- a/lib/hooks/use-intersection-observer.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { RefObject, useEffect, useState } from "react"; - -interface Args extends IntersectionObserverInit { - freezeOnceVisible?: boolean; -} - -function useIntersectionObserver( - elementRef: RefObject, - { - threshold = 0, - root = null, - rootMargin = "0%", - freezeOnceVisible = false, - }: Args -): IntersectionObserverEntry | undefined { - const [entry, setEntry] = useState(); - - const frozen = entry?.isIntersecting && freezeOnceVisible; - - const updateEntry = ([entry]: IntersectionObserverEntry[]): void => { - setEntry(entry); - }; - - useEffect(() => { - const node = elementRef?.current; // DOM Ref - const hasIOSupport = !!window.IntersectionObserver; - - if (!hasIOSupport || frozen || !node) return; - - const observerParams = { threshold, root, rootMargin }; - const observer = new IntersectionObserver(updateEntry, observerParams); - - observer.observe(node); - - return () => observer.disconnect(); - - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [threshold, root, rootMargin, frozen]); - - return entry; -} - -export default useIntersectionObserver; diff --git a/lib/prisma.tsx b/lib/prisma.tsx deleted file mode 100644 index b9fdb66..0000000 --- a/lib/prisma.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { PrismaClient } from "@prisma/client"; - -declare global { - var prisma: PrismaClient | undefined; -} - -const prisma = global.prisma || new PrismaClient(); - -if (process.env.NODE_ENV === "development") global.prisma = prisma; - -export { prisma }; diff --git a/prisma/schema.prisma b/prisma/schema.prisma deleted file mode 100644 index ecbfa64..0000000 --- a/prisma/schema.prisma +++ /dev/null @@ -1,78 +0,0 @@ -datasource db { - provider = "postgresql" - url = env("POSTGRES_PRISMA_URL") // uses connection pooling - directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection - shadowDatabaseUrl = env("POSTGRES_URL_NON_POOLING") // used for migrations -} - -generator client { - provider = "prisma-client-js" - previewFeatures = ["jsonProtocol"] -} - -model Chat { - id String @id @default(cuid()) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - title String - messages Message[] - userId String? -} - -model Message { - id String @id @default(cuid()) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - content String - role String - chat Chat @relation(fields: [chatId], references: [id], onDelete: Cascade) - chatId String -} - -model Account { - id String @id @default(cuid()) - userId String - type String - provider String - providerAccountId String - refresh_token String? @db.Text - access_token String? @db.Text - expires_at Int? - token_type String? - scope String? - id_token String? @db.Text - session_state String? - - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - - @@unique([provider, providerAccountId]) - @@index([userId]) -} - -model Session { - id String @id @default(cuid()) - sessionToken String @unique - userId String - expires DateTime - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - - @@index([userId]) -} - -model User { - id String @id @default(cuid()) - name String? - email String? @unique - emailVerified DateTime? - image String? - accounts Account[] - sessions Session[] -} - -model VerificationToken { - identifier String - token String @unique - expires DateTime - - @@unique([identifier, token]) -}