From aa31d72de2cc4fb5204a415b86f592342b96111d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20Akg=C3=BCl?= <s86116@bht-berlin.de> Date: Thu, 15 Jun 2023 01:37:07 +0200 Subject: [PATCH] update + gweet model + preparing backend change --- app/api/comments/route.ts | 66 --------- app/api/likes/likeService.ts | 117 --------------- app/api/likes/route.ts | 37 ----- app/api/messages/route.ts | 50 ------- app/api/{ => users}/favgameslist/route.ts | 0 app/loading.tsx | 14 ++ components/addGameToList.tsx | 4 +- components/post-gweets.tsx | 4 +- components/post-item.tsx | 64 ++++----- components/post-like-button.tsx | 91 +++++------- package-lock.json | 165 ++++++++++++---------- package.json | 14 +- prisma/schema.prisma | 157 ++++++++++++-------- 13 files changed, 278 insertions(+), 505 deletions(-) delete mode 100644 app/api/comments/route.ts delete mode 100644 app/api/likes/likeService.ts delete mode 100644 app/api/likes/route.ts delete mode 100644 app/api/messages/route.ts rename app/api/{ => users}/favgameslist/route.ts (100%) create mode 100644 app/loading.tsx diff --git a/app/api/comments/route.ts b/app/api/comments/route.ts deleted file mode 100644 index 13e15c2..0000000 --- a/app/api/comments/route.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { db } from "@/lib/db"; -import { getCurrentUser } from "@/lib/session"; -import { revalidatePath } from "next/cache"; -import { NextRequest, NextResponse } from "next/server"; - -export async function POST(req: NextRequest) { - const user = await getCurrentUser(); - - if (!user) { - return NextResponse.json({ status: 401, message: 'Unauthorized' }); - } - - const userId = user.id; - const content = await req.json() - - try { - await db.comment.create({ - data: { - message: content.gweet, - postId: content.postId, - userId: userId, - } - }) - const path = req.nextUrl.searchParams.get('path') || '/'; - revalidatePath(path); - - return NextResponse.json({ status: 201, message: 'Comment Created' }) - - } catch (error: any) { - return NextResponse.json({ status: 500, message: error.message }) - } -} - -export async function GET(req: NextRequest): Promise<NextResponse> { - const pa = req.nextUrl.searchParams; - - try { - const p = pa.get('postid') - - if (!p) { - return NextResponse.json({ status: 400, message: 'Bad Request' }) - } - - const message = await db.post.findUnique({ - where: { - id: p - }, - include: { - user: true, - }, - }) - - const comments = await db.comment.findMany({ - where: { - postId: p - }, - orderBy: { - createdAt: "desc" - } - }) - - return NextResponse.json(comments); - } catch (error) { - return NextResponse.json(error, { status: 500 }); - } -} \ No newline at end of file diff --git a/app/api/likes/likeService.ts b/app/api/likes/likeService.ts deleted file mode 100644 index 18f9807..0000000 --- a/app/api/likes/likeService.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { db } from "@/lib/db" -import { Prisma } from "@prisma/client" - -type likeType = Prisma.LikeUncheckedCreateInput - -/** - * Creates like if user has not liked this post. - * Deletes like if user has liked post already. - */ -export async function putLike(like: likeType): Promise<likeType | undefined> { - // check if like exists by this user and for this post - // if exists delete - // if not create - try { - const actualLike = await db.like.findFirst({ - where: { - // id: like.id, - postId: like.postId, - userId: like.userId - } - }) - console.log("found like: ", actualLike?.id) - if (actualLike == null) { - console.log("like is null", "postid:", like.postId, "so create it") - throw Error("Message was not liked by this user") - } - console.log("delete like", like.postId, "likeid: ", actualLike?.id) - await db.like.delete({ - where: { - id: actualLike.id - } - }) - - /* const msg = await db.post.update({ - where: { - id: like.postId - }, - data: { - likeCount: { increment: -1 } - } - }) */ - - return undefined; - - } catch { - - const createdLike = await db.like.create({ - data: { - postId: like.postId, - userId: like.userId - } - }) - - const updatedMessage = await db.post.update({ - where: { - id: like.postId - }, - data: { - likeCount: { increment: 1 } - } - }) - } -} - -export async function putLikeComment(like: likeType) { - // check if like exists by this user and for this post - // if exists delete - // if not create - try { - const actualLike = await db.like.findFirst({ - where: { - // id: like.id, - postId: like.postId, - commentId: like.commentId, - userId: like.userId - } - }) - console.log("found like: ", actualLike?.id) - if (actualLike == null) { - console.log("like is null", like.commentId, "so create it") - const createdLike = await db.like.create({ - data: { - postId: like.postId, - userId: like.userId, - commentId: like.commentId - } - }) - } else { - console.log("delete like", like.commentId, "postid:", like.postId, "likeid: ", actualLike?.id) - await db.like.delete({ - where: { - id: actualLike.id - } - }) - } - - /* const msg = await db.comment.update({ - where: { - id: like.postId - }, - data: { - likeCount: { increment: -1 } - } - }) */ - - } catch { - - /* const updatedMessage = await db.comment.update({ - where: { - id: like.postId - }, - data: { - likeCount: { increment: 1 } - } - }) */ - } -} \ No newline at end of file diff --git a/app/api/likes/route.ts b/app/api/likes/route.ts deleted file mode 100644 index 35619aa..0000000 --- a/app/api/likes/route.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Prisma } from "@prisma/client"; -import { NextRequest, NextResponse } from "next/server"; -import { putLike, putLikeComment } from "./likeService"; -import { getServerSession } from "next-auth/next"; -import { authOptions } from "@/lib/auth"; -import { revalidatePath } from "next/cache"; - -type like = Prisma.LikeUncheckedCreateInput - -export async function PUT(req: NextRequest) { - const session = await getServerSession(authOptions); - - if (!session) { - return NextResponse.json({ status: 401 }); - } - - const userId = session.user.id - - const data: like = await req.json() - data.userId = userId; - - console.log("router data: " + data, "status:") - try { - if (data.commentId == undefined) { - const msg = await putLike(data) - } else { - putLikeComment(data) - } - const path = req.nextUrl.searchParams.get('path') || '/'; - revalidatePath(path); - return NextResponse.json({ status: 200, message: 'Like handled' }) - - } catch (error) { - console.log("fail" + error); - return NextResponse.json(error, { status: 500 }); - } -} \ No newline at end of file diff --git a/app/api/messages/route.ts b/app/api/messages/route.ts deleted file mode 100644 index 6eb3296..0000000 --- a/app/api/messages/route.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { db } from "@/lib/db"; -import { getCurrentUser } from "@/lib/session"; -import { revalidatePath } from "next/cache"; -import { NextRequest, NextResponse } from "next/server"; - -export async function POST(req: NextRequest) { - const user = await getCurrentUser(); - - if (!user) { - return NextResponse.json({ status: 401, message: 'Unauthorized' }); - } - - const userId = user.id; - const content = await req.json() - - try { - await db.post.create({ - data: { - content: content.gweet, - userId: userId, - } - }) - const path = req.nextUrl.searchParams.get('path') || '/'; - revalidatePath(path); - - return NextResponse.json({ status: 201, message: 'Message Created' }) - - } catch (error: any) { - return NextResponse.json({ status: 500, message: error.message }) - } -} - -export async function GET() { - try { - const messages = await db.post.findMany({ - orderBy: { - createdAt: "desc" - }, - include: { - user: true, - Comment: true, - Like: true - }, - }) - - return NextResponse.json(messages); - } catch (error) { - return NextResponse.json(error, { status: 500 }); - } -} \ No newline at end of file diff --git a/app/api/favgameslist/route.ts b/app/api/users/favgameslist/route.ts similarity index 100% rename from app/api/favgameslist/route.ts rename to app/api/users/favgameslist/route.ts diff --git a/app/loading.tsx b/app/loading.tsx new file mode 100644 index 0000000..edd557e --- /dev/null +++ b/app/loading.tsx @@ -0,0 +1,14 @@ +import { Card } from "@/components/ui/card"; +import { Skeleton } from "@/components/ui/skeleton"; + +export default function Loading() { + return ( + <main className="main-content"> + <div className="flex justify-center"> + <Card className="p-6 w-full"> + <Skeleton className="bg-gray-300" /> + </Card> + </div> + </main> + ) +} \ No newline at end of file diff --git a/components/addGameToList.tsx b/components/addGameToList.tsx index ebb42ad..e6fa3aa 100644 --- a/components/addGameToList.tsx +++ b/components/addGameToList.tsx @@ -15,7 +15,7 @@ export default function AddGameToList(props: { userGameList: Number[], gameId: s formData.gameId = gameId; formData.add = false; - const response = await fetch('/api/favgameslist', { + const response = await fetch('/api/users/favgameslist', { method: 'PUT', body: JSON.stringify(formData) }) @@ -33,7 +33,7 @@ export default function AddGameToList(props: { userGameList: Number[], gameId: s formData.gameId = gameId; formData.add = true; - const response = await fetch('/api/favgameslist', { + const response = await fetch('/api/users/favgameslist', { method: 'PUT', body: JSON.stringify(formData) }) diff --git a/components/post-gweets.tsx b/components/post-gweets.tsx index 8dd8738..574ea7b 100644 --- a/components/post-gweets.tsx +++ b/components/post-gweets.tsx @@ -21,7 +21,7 @@ import { toast } from "@/components/ui/use-toast" import { useSession } from "next-auth/react" import { FormEvent, Fragment, useEffect, useState } from "react" import { Icons } from "./icons" -import PostItem from "./post-item" +// import PostItem from "./post-item" import { Card } from "./ui/card" import { Separator } from "./ui/separator" import { Skeleton } from "./ui/skeleton" @@ -140,7 +140,7 @@ export function PostGweets() { {messages.length > 0 ? ( messages.map((message: any) => ( <Fragment key={message.id}> - <PostItem msg={message} /> + {/* <PostItem msg={message} /> */} <Separator className="mt-3 mb-6" /> </Fragment> )) diff --git a/components/post-item.tsx b/components/post-item.tsx index bd2b548..1355f87 100644 --- a/components/post-item.tsx +++ b/components/post-item.tsx @@ -1,34 +1,34 @@ -import { formatTimeElapsed } from "@/lib/utils"; -import { IPost } from "@/types/prisma-item"; -// import CommentButton from "./post-comment-button"; +// import { formatTimeElapsed } from "@/lib/utils"; +// import { IPost } from "@/types/prisma-item"; +// // import CommentButton from "./post-comment-button"; // import LikeButton from "./post-like-button"; -import { UserAvatar } from "./user-avatar"; +// import { UserAvatar } from "./user-avatar"; -export default function PostItem({ msg }: { msg: IPost }) { - return ( - <div className="flex"> - <UserAvatar - user={{ name: msg.user.username || null, image: msg.user.image || null }} - className="h-10 w-10" - /> - <div className="ml-4 flex flex-col flex-grow"> - <div> - <div className="flex items-center"> - <h1 className="font-bold mr-2">{msg.user.name}</h1> - <h1 className="text-sky-500 text-sm"> - @{msg.user.username} - </h1> - <h1 className="text-gray-500 text-sm ml-auto"> - {formatTimeElapsed(msg.createdAt)} - </h1> - </div> - <h1>{msg.content}</h1> - </div> - {/* <div className="flex justify-end" > - <LikeButton data={msg} /> - <CommentButton data={msg} /> - </div> */} - </div> - </div> - ) -} \ No newline at end of file +// export default function PostItem({ msg }: { msg: IPost }) { +// return ( +// <div className="flex"> +// <UserAvatar +// user={{ name: msg.user.username || null, image: msg.user.image || null }} +// className="h-10 w-10" +// /> +// <div className="ml-4 flex flex-col flex-grow"> +// <div> +// <div className="flex items-center"> +// <h1 className="font-bold mr-2">{msg.user.name}</h1> +// <h1 className="text-sky-500 text-sm"> +// @{msg.user.username} +// </h1> +// <h1 className="text-gray-500 text-sm ml-auto"> +// {formatTimeElapsed(msg.createdAt)} +// </h1> +// </div> +// <h1>{msg.content}</h1> +// </div> +// <div className="flex justify-end" > +// <LikeButton data={msg} /> +// {/* <CommentButton data={msg} /> */} +// </div> +// </div> +// </div> +// ) +// } \ No newline at end of file diff --git a/components/post-like-button.tsx b/components/post-like-button.tsx index 4a8d923..d243329 100644 --- a/components/post-like-button.tsx +++ b/components/post-like-button.tsx @@ -12,64 +12,37 @@ // // type commentWithLikes = Prisma.CommentGetPayload<typeof commentWithPosts> // export default function LikeButton(props: { data: any }) { -// const router = useRouter(); -// const likeCount = props.data.Like.length -// // const likeCount = countLikes(likeArray, props.data); - -// async function postLike(e: any) { -// e.preventDefault() -// const postLikeData = props.data; -// const likeData = {} as likeType - -// if (postLikeData.postId == undefined) { -// likeData.postId = postLikeData.id! -// } else { -// likeData.postId = postLikeData.postId -// likeData.commentId = postLikeData.id +// const router = useRouter(); +// const likeCount = props.data.Like.length +// // const likeCount = countLikes(likeArray, props.data); + +// async function postLike(e: any) { +// e.preventDefault() +// const postLikeData = props.data; +// const likeData = {} as likeType + +// if (postLikeData.postId == undefined) { +// likeData.postId = postLikeData.id! +// } else { +// likeData.postId = postLikeData.postId +// likeData.commentId = postLikeData.id +// } +// likeData.userId = postLikeData.userId + +// const response = await fetch('/api/likes', { +// method: 'PUT', +// body: JSON.stringify(likeData) +// }) + +// return await response.json() // } -// likeData.userId = postLikeData.userId - -// const response = await fetch('/api/likes', { -// method: 'PUT', -// body: JSON.stringify(likeData) -// }) - -// startTransition(() => { -// // Refresh the current route and fetch new data from the server without -// // losing client-side browser or React state. -// router.refresh(); -// }); -// return await response.json() -// } - -// return ( -// <form onSubmit={postLike}> -// <Button type="submit" variant="ghost" size="lg" className="px-6 py-3" > -// <span className="pr-1">{likeCount}</span> -// <Icons.heart className="h-5 w-5" /> -// </Button> -// </form> -// ) -// } - -// function countLikes(likeArray: any, msg: any): number { -// let likeCount = 0; - -// if (msg.postId == undefined) { -// likeArray.forEach(function (like: any) { -// if (like.postId == undefined) { -// likeCount++; -// } -// }) -// } else { -// likeArray.forEach(function (like: any) { -// if (like.postId != undefined) { -// likeCount++; -// } -// }) -// } - - -// return likeCount; -// } +// return ( +// <form onSubmit={postLike}> +// <Button type="submit" variant="ghost" size="lg" className="px-6 py-3" > +// <span className="pr-1">{likeCount}</span> +// <Icons.heart className="h-5 w-5" /> +// </Button> +// </form> +// ) +// } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index fd7938a..5b52419 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,8 +25,8 @@ "bcrypt": "^5.1.0", "class-variance-authority": "^0.6.0", "clsx": "^1.2.1", - "lucide-react": "^0.236.0", - "next": "^13.4.4", + "lucide-react": "^0.241.0", + "next": "^13.4.5", "next-auth": "^4.22.1", "next-themes": "^0.2.1", "normalize-diacritics": "^4.0.0", @@ -34,19 +34,19 @@ "react-dom": "18.2.0", "react-hook-form": "^7.44.3", "react-infinite-scroll-component": "^6.1.0", - "tailwind-merge": "^1.13.0", - "tailwindcss-animate": "^1.0.5", + "tailwind-merge": "^1.13.1", + "tailwindcss-animate": "^1.0.6", "zod": "^3.21.4" }, "devDependencies": { "@tanstack/eslint-plugin-query": "^4.29.9", "@types/bcrypt": "^5.0.0", - "@types/node": "^20.2.5", - "@types/react": "^18.2.8", + "@types/node": "^20.3.0", + "@types/react": "^18.2.11", "@types/react-dom": "^18.2.4", "autoprefixer": "10.4.14", "eslint": "^8.42.0", - "eslint-config-next": "^13.4.4", + "eslint-config-next": "^13.4.5", "postcss": "8.4.24", "prisma": "^4.15.0", "tailwindcss": "3.3.2", @@ -317,23 +317,23 @@ } }, "node_modules/@next/env": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.4.tgz", - "integrity": "sha512-q/y7VZj/9YpgzDe64Zi6rY1xPizx80JjlU2BTevlajtaE3w1LqweH1gGgxou2N7hdFosXHjGrI4OUvtFXXhGLg==" + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.5.tgz", + "integrity": "sha512-SG/gKH6eij4vwQy87b/3mbpQ1X3x2vUdnpwq6/qL2IQWjtq58EY/UuNAp9CoEZoC9sI4L9AD1r+73Z9r4d3uug==" }, "node_modules/@next/eslint-plugin-next": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.4.tgz", - "integrity": "sha512-5jnh7q6I15efnjR/rR+/TGTc9hn53g3JTbEjAMjmeQiExKqEUgIXqrHI5zlTNlNyzCPkBB860/ctxXheZaF2Vw==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.5.tgz", + "integrity": "sha512-/xD/kyJhXmBZq+0xGKOdjL22c9/4i3mBAXaU9aOGEHTXqqFeOz8scJbScWF13aMqigeoFCsDqngIB2MIatcn4g==", "dev": true, "dependencies": { "glob": "7.1.7" } }, "node_modules/@next/swc-darwin-arm64": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.4.tgz", - "integrity": "sha512-xfjgXvp4KalNUKZMHmsFxr1Ug+aGmmO6NWP0uoh4G3WFqP/mJ1xxfww0gMOeMeSq/Jyr5k7DvoZ2Pv+XOITTtw==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.5.tgz", + "integrity": "sha512-XvTzi2ASUN5bECFIAAcBiSoDb0xsq+KLj4F0bof4d4rdc+FgOqLvseGQaOXwVi1TIh5bHa7o4b6droSJMO5+2g==", "cpu": [ "arm64" ], @@ -346,9 +346,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.4.tgz", - "integrity": "sha512-ZY9Ti1hkIwJsxGus3nlubIkvYyB0gNOYxKrfsOrLEqD0I2iCX8D7w8v6QQZ2H+dDl6UT29oeEUdDUNGk4UEpfg==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.5.tgz", + "integrity": "sha512-NQdqal/VKAqlJTuzhjZmNtdo8QSqwmfO7b2xJSAengTEVxQvsH76oGEzQeIv8Ci4NP6DysAFtFrJq++TmIxcUA==", "cpu": [ "x64" ], @@ -361,9 +361,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.4.tgz", - "integrity": "sha512-+KZnDeMShYkpkqAvGCEDeqYTRADJXc6SY1jWXz+Uo6qWQO/Jd9CoyhTJwRSxvQA16MoYzvILkGaDqirkRNctyA==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.5.tgz", + "integrity": "sha512-nB8TjtpJCXtzIFjYOMbnQu68ajkA8QK58TreHjTGojSQjsF0StDqo5zFHglVVVHrd8d3N/+EjC18yFNSWnd/ZA==", "cpu": [ "arm64" ], @@ -376,9 +376,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.4.tgz", - "integrity": "sha512-evC1twrny2XDT4uOftoubZvW3EG0zs0ZxMwEtu/dDGVRO5n5pT48S8qqEIBGBUZYu/Xx4zzpOkIxx1vpWdE+9A==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.5.tgz", + "integrity": "sha512-W126XUW599OV3giSH9Co40VpT8VAOT47xONVHXZaYEpeca0qEevjj6WUr5IJu/8u+XGWm5xI1S0DYWjR6W+olw==", "cpu": [ "arm64" ], @@ -391,9 +391,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.4.tgz", - "integrity": "sha512-PX706XcCHr2FfkyhP2lpf+pX/tUvq6/ke7JYnnr0ykNdEMo+sb7cC/o91gnURh4sPYSiZJhsF2gbIqg9rciOHQ==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.5.tgz", + "integrity": "sha512-ZbPLO/oztQdtjGmWvGhRmtkZ6j9kQqg65kiO7F7Ijj7ojTtu3hh/vY+XRsHa/4Cse6HgyJ8XGZJMGoLb8ecQfQ==", "cpu": [ "x64" ], @@ -406,9 +406,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.4.tgz", - "integrity": "sha512-TKUUx3Ftd95JlHV6XagEnqpT204Y+IsEa3awaYIjayn0MOGjgKZMZibqarK3B1FsMSPaieJf2FEAcu9z0yT5aA==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.5.tgz", + "integrity": "sha512-f+/h8KMNixVUoRB+2vza8I+jsthJ4KcvopGUsDIUHe7Q4t+m8nKwGFBeyNu9qNIenYK5g5QYEsSwYFEqZylrTQ==", "cpu": [ "x64" ], @@ -421,9 +421,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.4.tgz", - "integrity": "sha512-FP8AadgSq4+HPtim7WBkCMGbhr5vh9FePXiWx9+YOdjwdQocwoCK5ZVC3OW8oh3TWth6iJ0AXJ/yQ1q1cwSZ3A==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.5.tgz", + "integrity": "sha512-dvtPQZ5+J+zUE1uq7gP853Oj63e+n0T1ydZ/yRdVh7d8zW9ZFuC9fFrg3MqP1cv1NPPur8rrTqDKN2mRBkSSBw==", "cpu": [ "arm64" ], @@ -436,9 +436,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.4.tgz", - "integrity": "sha512-3WekVmtuA2MCdcAOrgrI+PuFiFURtSyyrN1I3UPtS0ckR2HtLqyqmS334Eulf15g1/bdwMteePdK363X/Y9JMg==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.5.tgz", + "integrity": "sha512-gK9zwGe25x31S4AjPy3Bf2niQvHIAbmwgkzmqWG3OmD4K2Z/Dh2ju4vuyzPzIt0pwQe4B520meP9NizTBmVWSg==", "cpu": [ "ia32" ], @@ -451,9 +451,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.4.tgz", - "integrity": "sha512-AHRITu/CrlQ+qzoqQtEMfaTu7GHaQ6bziQln/pVWpOYC1wU+Mq6VQQFlsDtMCnDztPZtppAXdvvbNS7pcfRzlw==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.5.tgz", + "integrity": "sha512-iyNQVc7eGehrik9RJt9xGcnO6b/pi8C7GCfg8RGenx1IlalEKbYRgBJloF7DQzwlrV47E9bQl8swT+JawaNcKA==", "cpu": [ "x64" ], @@ -1433,9 +1433,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.2.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", - "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", + "version": "20.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.0.tgz", + "integrity": "sha512-cumHmIAf6On83X7yP+LrsEyUOf/YlociZelmpRYaGFydoaPdxdt80MAbu6vWerQT2COCp2nPvHdsbD7tHn/YlQ==", "dev": true }, "node_modules/@types/prop-types": { @@ -1445,9 +1445,9 @@ "devOptional": true }, "node_modules/@types/react": { - "version": "18.2.8", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.8.tgz", - "integrity": "sha512-lTyWUNrd8ntVkqycEEplasWy2OxNlShj3zqS0LuB1ENUGis5HodmhM7DtCoUGbxj3VW/WsGA0DUhpG6XrM7gPA==", + "version": "18.2.11", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.11.tgz", + "integrity": "sha512-+hsJr9hmwyDecSMQAmX7drgbDpyE+EgSF6t7+5QEBAn1tQK7kl1vWZ4iRf6SjQ8lk7dyEULxUmZOIpN0W5baZA==", "devOptional": true, "dependencies": { "@types/prop-types": "*", @@ -2599,12 +2599,12 @@ } }, "node_modules/eslint-config-next": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.4.4.tgz", - "integrity": "sha512-z/PMbm6L0iC/fwISULxe8IVy4DtNqZk2wQY711o35klenq70O6ns82A8yuMVCFjHC0DIyB2lyugesRtuk9u8dQ==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.4.5.tgz", + "integrity": "sha512-7qgJmRp9ClRzPgkzEz7ahK+Rasiv4k2aU3eqkkORzseNUGdtImZVYomcXUhUheHwkxzdN2p//nbIA7zJrCxsCg==", "dev": true, "dependencies": { - "@next/eslint-plugin-next": "13.4.4", + "@next/eslint-plugin-next": "13.4.5", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.42.0", "eslint-import-resolver-node": "^0.3.6", @@ -3327,6 +3327,11 @@ "node": ">=10.13.0" } }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" + }, "node_modules/globals": { "version": "13.20.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", @@ -3392,8 +3397,7 @@ "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, "node_modules/graphemer": { "version": "1.4.0", @@ -4123,9 +4127,9 @@ } }, "node_modules/lucide-react": { - "version": "0.236.0", - "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.236.0.tgz", - "integrity": "sha512-himeKF7nVgOQ1BNcyBgk41E4/rcbmI6Zw8Q4o57nlynsFvIBA/DMacFpzKYdcyBReUj8jf08xTnCGyn/niLvwQ==", + "version": "0.241.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.241.0.tgz", + "integrity": "sha512-g22ci6iHuNc2hUwjiFz0D3jQQfQYrZBZesXG6+AX5rOV68Epttkt/nF6dMdz6reKJjtpoNzu+LKeKHGu/qjOgQ==", "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0" } @@ -4291,16 +4295,17 @@ "dev": true }, "node_modules/next": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/next/-/next-13.4.4.tgz", - "integrity": "sha512-C5S0ysM0Ily9McL4Jb48nOQHT1BukOWI59uC3X/xCMlYIh9rJZCv7nzG92J6e1cOBqQbKovlpgvHWFmz4eKKEA==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/next/-/next-13.4.5.tgz", + "integrity": "sha512-pfNsRLVM9e5Y1/z02VakJRfD6hMQkr24FaN2xc9GbcZDBxoOgiNAViSg5cXwlWCoMhtm4U315D7XYhgOr96Q3Q==", "dependencies": { - "@next/env": "13.4.4", + "@next/env": "13.4.5", "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", "postcss": "8.4.14", "styled-jsx": "5.1.1", + "watchpack": "2.4.0", "zod": "3.21.4" }, "bin": { @@ -4310,15 +4315,15 @@ "node": ">=16.8.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.4.4", - "@next/swc-darwin-x64": "13.4.4", - "@next/swc-linux-arm64-gnu": "13.4.4", - "@next/swc-linux-arm64-musl": "13.4.4", - "@next/swc-linux-x64-gnu": "13.4.4", - "@next/swc-linux-x64-musl": "13.4.4", - "@next/swc-win32-arm64-msvc": "13.4.4", - "@next/swc-win32-ia32-msvc": "13.4.4", - "@next/swc-win32-x64-msvc": "13.4.4" + "@next/swc-darwin-arm64": "13.4.5", + "@next/swc-darwin-x64": "13.4.5", + "@next/swc-linux-arm64-gnu": "13.4.5", + "@next/swc-linux-arm64-musl": "13.4.5", + "@next/swc-linux-x64-gnu": "13.4.5", + "@next/swc-linux-x64-musl": "13.4.5", + "@next/swc-win32-arm64-msvc": "13.4.5", + "@next/swc-win32-ia32-msvc": "13.4.5", + "@next/swc-win32-x64-msvc": "13.4.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -5794,9 +5799,9 @@ } }, "node_modules/tailwind-merge": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-1.13.0.tgz", - "integrity": "sha512-mUTmDbcU+IhOvJ0c42eLQ/nRkvolTqfpVaVQRSxfJAv9TabS6Y2zW/1wKpKLdKzyL3Gh8j6NTLl6MWNmvOM6kA==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-1.13.1.tgz", + "integrity": "sha512-tRtRN22TDokGi2TuYSvuHQuuW6BJ/zlUEG+iYpAQ9i66msc/0eU/+HPccbPnNNH0mCPp0Ob8thaC8Uy9CxHitQ==", "funding": { "type": "github", "url": "https://github.com/sponsors/dcastil" @@ -5840,9 +5845,9 @@ } }, "node_modules/tailwindcss-animate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/tailwindcss-animate/-/tailwindcss-animate-1.0.5.tgz", - "integrity": "sha512-UU3qrOJ4lFQABY+MVADmBm+0KW3xZyhMdRvejwtXqYOL7YjHYxmuREFAZdmVG5LPe5E9CAst846SLC4j5I3dcw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/tailwindcss-animate/-/tailwindcss-animate-1.0.6.tgz", + "integrity": "sha512-4WigSGMvbl3gCCact62ZvOngA+PRqhAn7si3TQ3/ZuPuQZcIEtVap+ENSXbzWhpojKB8CpvnIsrwBu8/RnHtuw==", "peerDependencies": { "tailwindcss": ">=3.0.0 || insiders" } @@ -6151,6 +6156,18 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/watchpack": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", + "dependencies": { + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/package.json b/package.json index 3f8968c..7584f75 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "bcrypt": "^5.1.0", "class-variance-authority": "^0.6.0", "clsx": "^1.2.1", - "lucide-react": "^0.236.0", - "next": "^13.4.4", + "lucide-react": "^0.241.0", + "next": "^13.4.5", "next-auth": "^4.22.1", "next-themes": "^0.2.1", "normalize-diacritics": "^4.0.0", @@ -38,19 +38,19 @@ "react-dom": "18.2.0", "react-hook-form": "^7.44.3", "react-infinite-scroll-component": "^6.1.0", - "tailwind-merge": "^1.13.0", - "tailwindcss-animate": "^1.0.5", + "tailwind-merge": "^1.13.1", + "tailwindcss-animate": "^1.0.6", "zod": "^3.21.4" }, "devDependencies": { "@tanstack/eslint-plugin-query": "^4.29.9", "@types/bcrypt": "^5.0.0", - "@types/node": "^20.2.5", - "@types/react": "^18.2.8", + "@types/node": "^20.3.0", + "@types/react": "^18.2.11", "@types/react-dom": "^18.2.4", "autoprefixer": "10.4.14", "eslint": "^8.42.0", - "eslint-config-next": "^13.4.4", + "eslint-config-next": "^13.4.5", "postcss": "8.4.24", "prisma": "^4.15.0", "tailwindcss": "3.3.2", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8ba0bb4..33fc100 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -14,17 +14,18 @@ model Account { type String provider String providerAccountId String - refresh_token String? - access_token String? + refresh_token String? @db.Text + access_token String? @db.Text expires_at Int? token_type String? scope String? - id_token String? + id_token String? @db.Text session_state String? createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @default(now()) @map("updated_at") refresh_token_expires_in Int? - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([provider, providerAccountId]) @@map("accounts") @@ -35,91 +36,129 @@ model Session { sessionToken String @unique userId String @unique expires DateTime - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map("sessions") } +model VerificationToken { + identifier String + token String @unique + expires DateTime + + @@unique([identifier, token]) + @@map("verification_tokens") +} + model User { id String @id @default(cuid()) - name String? - username String? @unique - email String? @unique - emailVerified DateTime? + name String + username String @unique + email String @unique + emailVerified DateTime? @map("email_verified") password String? image String? createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @default(now()) @map("updated_at") - favGameList Int[] - accounts Account? - Comment Comment[] - following Follows[] @relation("following") - followers Follows[] @relation("follower") - Like Like[] - Post Post[] - sessions Session? - @@map("users") -} + favGameList Int[] -model VerificationToken { - identifier String - token String @unique - expires DateTime + accounts Account? + sessions Session? - @@unique([identifier, token]) - @@map("verification_tokens") + gweets Gweet[] + likes Like[] + + following Follows[] @relation("following") + followers Follows[] @relation("follower") + + @@map("users") } model Follows { followerId String followingId String - createdAt DateTime @default(now()) - follower User @relation("following", fields: [followerId], references: [id]) - following User @relation("follower", fields: [followingId], references: [id]) + createdAt DateTime @default(now()) @map("created_at") + + follower User @relation("following", fields: [followerId], references: [id]) + following User @relation("follower", fields: [followingId], references: [id]) @@id([followerId, followingId]) @@map("follows") } -model Post { - id String @id @default(cuid()) - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime @default(now()) @map("updated_at") - userId String +model Gweet { + id String @id @default(cuid()) + userId String @map("user_id") content String - likeCount Int? @default(0) - published Boolean @default(false) - Comment Comment[] - Like Like[] - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + likeCount Int @default(0) @map("like_count") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @default(now()) @map("updated_at") - @@map("posts") + replyToUserId String? @map("reply_to_user_id") + replyToGweetId String? @map("reply_to_gweet_id") + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + comment Gweet? @relation("gweet_comment", fields: [replyToGweetId], references: [id]) + allComments Gweet[] @relation("gweet_comment") + likes Like[] + + @@map("gweets") } model Like { id String @id @default(cuid()) - postId String - commentId String? - userId String - comment Comment? @relation(fields: [commentId], references: [id], onDelete: Cascade) - post Post @relation(fields: [postId], references: [id], onDelete: Cascade) - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + gweetId String @map("gweet_id") + userId String @map("user_id") + createdAt DateTime @default(now()) @map("created_at") + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + gweet Gweet @relation(fields: [gweetId], references: [id], onDelete: Cascade) @@map("likes") } -model Comment { - id String @id @default(cuid()) - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime @default(now()) @map("updated_at") - message String - likeCount Int? @default(0) - postId String - userId String - post Post @relation(fields: [postId], references: [id], onDelete: Cascade) - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - Like Like[] - - @@map("comments") -} +// model Post { +// id String @id @default(cuid()) +// userId String +// content String +// likeCount Int? @default(0) +// createdAt DateTime @default(now()) @map("created_at") +// updatedAt DateTime @default(now()) @map("updated_at") + +// user User @relation(fields: [userId], references: [id], onDelete: Cascade) +// Comment Comment[] +// Like Like[] + +// @@map("posts") +// } + +// model Comment { +// id String @id @default(cuid()) +// createdAt DateTime @default(now()) @map("created_at") +// updatedAt DateTime @default(now()) @map("updated_at") +// message String +// likeCount Int? @default(0) +// postId String +// userId String + +// user User @relation(fields: [userId], references: [id], onDelete: Cascade) +// post Post @relation(fields: [postId], references: [id], onDelete: Cascade) +// Like Like[] + +// @@map("comments") +// } + +// model Like { +// id String @id @default(cuid()) +// postId String +// commentId String? +// userId String + +// user User @relation(fields: [userId], references: [id], onDelete: Cascade) +// post Post @relation(fields: [postId], references: [id], onDelete: Cascade) +// comment Comment? @relation(fields: [commentId], references: [id], onDelete: Cascade) + +// @@map("likes") +// } -- GitLab