Skip to content

Commit

Permalink
fix[PRISMA] : Correct file structure, export
Browse files Browse the repository at this point in the history
BUG's after Bugs need to check for api endpoints and server side errors
  • Loading branch information
parazeeknova committed Oct 10, 2024
1 parent b9542bb commit 19450f8
Show file tree
Hide file tree
Showing 35 changed files with 54 additions and 41 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public-hoist-pattern[]=*prisma*
2 changes: 1 addition & 1 deletion apps/web/src/app/(auth)/login/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { verify } from "@node-rs/argon2";
import { lucia } from "@zephyr/auth/auth";
import { type LoginValues, loginSchema } from "@zephyr/auth/validation";
import prisma from "@zephyr/db/prisma";
import { prisma } from "@zephyr/db";
import { isRedirectError } from "next/dist/client/components/redirect";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/(auth)/signup/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { redirect } from "next/navigation";

import { lucia } from "@zephyr/auth/auth";
import { type SignUpValues, signUpSchema } from "@zephyr/auth/validation";
import prisma from "@zephyr/db/prisma";
import { prisma } from "@zephyr/db";

export async function signUp(
credentials: SignUpValues
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/posts/[id]/vote/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextRequest } from "next/server";

import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { prisma } from "@zephyr/db";

export async function POST(
req: NextRequest,
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/app/api/posts/following/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { NextRequest } from "next/server";

import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { type PostsPage, getPostDataInclude } from "@zephyr/db/prisma/client";
import { type PostsPage, getPostDataInclude, prisma } from "@zephyr/db";

export async function GET(req: NextRequest) {
try {
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/app/api/posts/for-you/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { NextRequest } from "next/server";

import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { type PostsPage, getPostDataInclude } from "@zephyr/db/prisma/client";
import { type PostsPage, getPostDataInclude, prisma } from "@zephyr/db";

export async function GET(req: NextRequest) {
try {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/app/api/users/[userId]/followers/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import type { FollowerInfo } from "@zephyr/db/prisma/client";
import type { FollowerInfo } from "@zephyr/db";
import { prisma } from "@zephyr/db";

export async function GET(
_req: Request,
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/app/api/users/[userId]/posts/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { NextRequest } from "next/server";

import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { type PostsPage, getPostDataInclude } from "@zephyr/db/prisma/client";
import { type PostsPage, getPostDataInclude, prisma } from "@zephyr/db";

export async function GET(
req: NextRequest,
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/app/api/users/[userId]/profile/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { NextRequest } from "next/server";

import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { getUserDataSelect } from "@zephyr/db/prisma/client";
import { getUserDataSelect, prisma } from "@zephyr/db";

export async function GET(
_req: NextRequest,
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/app/api/users/followed/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { getUserDataSelect } from "@zephyr/db/prisma/client";
import { getUserDataSelect, prisma } from "@zephyr/db";

export async function GET() {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextRequest } from "next/server";

import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { prisma } from "@zephyr/db";

export async function GET(
_req: NextRequest,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/FeedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, { useEffect, useRef, useState } from "react";

import { Card, CardContent } from "@/components/ui/card";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import type { PostData } from "@zephyr/db/prisma/client";
import type { PostData } from "@zephyr/db";
import PostCard from "./feedview/postCard";
import StoryCard from "./feedview/storyCard";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/ForYouFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Loader2 } from "lucide-react";
import kyInstance from "@/lib/ky";
import InfiniteScrollContainer from "@zephyr-ui/Layouts/InfiniteScrollContainer";
import PostsLoadingSkeleton from "@zephyr-ui/Posts/PostsLoadingSkeleton";
import type { PostsPage } from "@zephyr/db/prisma/client";
import type { PostsPage } from "@zephyr/db";

import FeedView from "./FeedView";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/feedview/postCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { formatRelativeDate } from "@/lib/utils";
import { useVoteMutation } from "@/posts/aura/auraMutations";
import UserAvatar from "@zephyr-ui/Layouts/UserAvatar";
import PostMoreButton from "@zephyr-ui/Posts/PostMoreButton";
import type { PostData } from "@zephyr/db/prisma/client";
import type { PostData } from "@zephyr/db";
interface PostCardProps {
post: PostData;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/sidebars/left/Friends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import React from "react";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardTitle } from "@/components/ui/card";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import type { UserData } from "@/db/client";
import { useFollowedUsers } from "@/hooks/userFollowerInfo";
import { useUnfollowUserMutation } from "@/hooks/userMutations";
import UserAvatar from "@zephyr-ui/Layouts/UserAvatar";
import type { UserData } from "@zephyr/db/prisma/client";

import UnfollowUserDialog from "@zephyr-ui/Layouts/UnfollowUserDialog";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Layouts/Following.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Loader2 } from "lucide-react";
import kyInstance from "@/lib/ky";
import InfiniteScrollContainer from "@zephyr-ui/Layouts/InfiniteScrollContainer";
import PostsLoadingSkeleton from "@zephyr-ui/Posts/PostsLoadingSkeleton";
import type { PostsPage } from "@zephyr/db/prisma/client";
import type { PostsPage } from "@zephyr/db";

import FeedView from "@zephyr-ui/Home/FeedView";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Layouts/UnfollowUserDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
DialogTitle
} from "@/components/ui/dialog";
import { useUnfollowUserMutation } from "@/hooks/userMutations";
import type { UserData } from "@zephyr/db/prisma/client";
import type { UserData } from "@zephyr/db";

import LoadingButton from "@zephyr-ui/Auth/LoadingButton";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Posts/DeletePostDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DialogTitle
} from "@/components/ui/dialog";
import { useDeletePostMutation } from "@/posts/mutations";
import type { PostData } from "@zephyr/db/prisma/client";
import type { PostData } from "@zephyr/db";

import LoadingButton from "@zephyr-ui/Auth/LoadingButton";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Posts/PostMoreButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DropdownMenuItem,
DropdownMenuTrigger
} from "@/components/ui/dropdown-menu";
import type { PostData } from "@zephyr/db/prisma/client";
import type { PostData } from "@zephyr/db";

import DeletePostDialog from "./DeletePostDialog";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/hooks/userFollowerInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery } from "@tanstack/react-query";

import kyInstance from "@/lib/ky";
import type { FollowerInfo, UserData } from "@zephyr/db/prisma/client";
import type { FollowerInfo, UserData } from "@zephyr/db";

export default function useFollowerInfo(
userId: string,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/hooks/userMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";

import { useToast } from "@/hooks/use-toast";
import kyInstance from "@/lib/ky";
import type { UserData } from "@zephyr/db/prisma/client";
import type { UserData } from "@zephyr/db";

async function followUser(userId: string): Promise<UserData> {
return kyInstance.post(`/api/users/${userId}/followers`).json<UserData>();
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/posts/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use server";

import prisma from "@zephyr/db/prisma";
import { getPostDataInclude } from "@zephyr/db/prisma/client";
import { getPostDataInclude, prisma } from "@zephyr/db";

import { validateRequest } from "@zephyr/auth/auth";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/posts/aura/auraMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";

import { useToast } from "@/hooks/use-toast";
import kyInstance from "@/lib/ky";
import type { PostData } from "@zephyr/db/prisma/client";
import type { PostData } from "@zephyr/db";

export function useVoteMutation() {
const queryClient = useQueryClient();
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/posts/editor/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import { validateRequest } from "@zephyr/auth/auth";
import { createPostSchema } from "@zephyr/auth/validation";
import prisma from "@zephyr/db/prisma";
import { getPostDataInclude } from "@zephyr/db/prisma/client";
import { getPostDataInclude, prisma } from "@zephyr/db";

export async function submitPost(input: string) {
const { user } = await validateRequest();
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/posts/editor/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@tanstack/react-query";

import { useToast } from "@/hooks/use-toast";
import type { PostsPage } from "@zephyr/db/prisma/client";
import type { PostsPage } from "@zephyr/db";

import { submitPost } from "./actions";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/posts/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { usePathname, useRouter } from "next/navigation";

import { useToast } from "@/hooks/use-toast";
import type { PostsPage } from "@zephyr/db/prisma/client";
import type { PostsPage } from "@zephyr/db";

import { deletePost } from "./actions";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/state/TopicActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { unstable_cache } from "next/cache";

import prisma from "@zephyr/db/prisma";
import { prisma } from "@zephyr/db";

export const getTrendingTopics = unstable_cache(
async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/state/UserActions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use server";

import { validateRequest } from "@zephyr/auth/auth";
import prisma from "@zephyr/db/prisma";
import { prisma } from "@zephyr/db";

export async function getSuggestedConnections() {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
import { prisma } from "@zephyr/db/prisma";
import { prisma } from "@zephyr/db";
import { Lucia, type Session, type User } from "lucia";
import { cookies } from "next/headers";
import { cache } from "react";
Expand Down
2 changes: 2 additions & 0 deletions packages/db/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./src/client";
export { default as prisma } from "./src/prisma";
9 changes: 9 additions & 0 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
"version": "0.0.1",
"license": "AGPL-3.0",
"private": true,
"exports": {
".": "./index.ts"
},
"dependencies": {
"@prisma/client": "^5.20.0"
},
"scripts": {
"db:generate": "prisma generate",
"db:migrate": "prisma migrate dev",
"db:studio": "prisma studio",
"db:push": "prisma db push --skip-generate"
},
"devDependencies": {
"@types/node": "^22.7.5",
"@zephyr/config": "workspace:*",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/db/prisma.ts → packages/db/src/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ declare global {

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;

export default prisma;
3 changes: 2 additions & 1 deletion packages/db/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"outDir": "dist",
"baseUrl": "."
},
"include": ["./*.ts", "**/*.ts"]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "tsup.config.ts"],
"exclude": ["node_modules"]
}
11 changes: 9 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
"$schema": "https://turbo.build/schema.json",
"ui": "tui",
"tasks": {
"db:generate": {
"cache": false
},
"db:push": {
"cache": false
},
"build": {
"dependsOn": ["^build"],
"dependsOn": ["^db:generate", "^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": [".next/**", "!.next/cache/**"]
},
"lint": {
"dependsOn": ["^lint"]
},
"dev": {
"cache": false,
"dependsOn": ["^db:generate"],
"cache": true,
"persistent": true
}
}
Expand Down

0 comments on commit 19450f8

Please sign in to comment.