diff --git a/src/app/(auth)/components/index.tsx b/src/app/(auth)/components/index.tsx index fd2fdacc..ee23a882 100644 --- a/src/app/(auth)/components/index.tsx +++ b/src/app/(auth)/components/index.tsx @@ -1,6 +1,6 @@ "use client" -import { startTransition, Suspense, useEffect, useState } from "react" +import { startTransition, Suspense, useState } from "react" import styles from "./auth.module.css" import Link from "../../components/link" import { signIn } from "next-auth/react" diff --git a/src/lib/server/prisma.ts b/src/lib/server/prisma.ts index af33d610..3a67dbc1 100644 --- a/src/lib/server/prisma.ts +++ b/src/lib/server/prisma.ts @@ -6,6 +6,7 @@ declare global { import config from "@lib/config" import { Post, PrismaClient, User, Prisma } from "@prisma/client" import * as crypto from "crypto" +import { cache } from "react" export type { User, File, Post } from "@prisma/client" export const prisma = @@ -209,12 +210,16 @@ export const getPostById = async ( return post } -export const getAllPosts = async ( - options?: Prisma.PostFindManyArgs -): Promise => { - const posts = await prisma.post.findMany(options) - return posts -} +export const getAllPosts = cache( + async ( + options?: Prisma.PostFindManyArgs + ): Promise< + Post[] | ServerPostWithFiles[] | ServerPostWithFilesAndAuthor[] + > => { + const posts = await prisma.post.findMany(options) + return posts + } +) export const userWithPosts = Prisma.validator()({ include: {