From b7a2f594646431433e8d2e48f79999c2b3e46853 Mon Sep 17 00:00:00 2001 From: pheralb Date: Tue, 12 Mar 2024 12:23:01 +0000 Subject: [PATCH] Update import paths for ``auth`` module & t3/env config file --- src/app/api/auth/[...nextauth]/route.ts | 4 +--- src/app/api/url/route.ts | 2 +- src/app/dashboard/settings/page.tsx | 2 +- src/components/auth/user-button.tsx | 2 +- src/components/links/create-link.tsx | 2 +- src/server/actions/auth.ts | 2 +- src/server/actions/links.ts | 18 +++++++++--------- src/server/db.ts | 2 +- src/server/mail.ts | 2 +- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts index 041478e..2e06971 100644 --- a/src/app/api/auth/[...nextauth]/route.ts +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -1,3 +1 @@ -import { handlers } from "auth"; - -export const { GET, POST } = handlers; +export { GET, POST } from "@/auth"; diff --git a/src/app/api/url/route.ts b/src/app/api/url/route.ts index 602caf0..700f8f7 100644 --- a/src/app/api/url/route.ts +++ b/src/app/api/url/route.ts @@ -16,7 +16,7 @@ export const GET = async (req: NextRequest) => { } // Get data from query: - const data = (await db.link.findFirst({ + const data = (await db.links.findFirst({ where: { slug: { equals: params, diff --git a/src/app/dashboard/settings/page.tsx b/src/app/dashboard/settings/page.tsx index 2f1bc5f..ba7164d 100644 --- a/src/app/dashboard/settings/page.tsx +++ b/src/app/dashboard/settings/page.tsx @@ -1,4 +1,4 @@ -import { auth, signOut } from "auth"; +import { auth, signOut } from "@/auth"; const SettingsPage = async () => { const session = await auth(); diff --git a/src/components/auth/user-button.tsx b/src/components/auth/user-button.tsx index 6b38ee8..652a92b 100644 --- a/src/components/auth/user-button.tsx +++ b/src/components/auth/user-button.tsx @@ -1,6 +1,6 @@ import Link from "next/link"; -import { auth } from "auth"; +import { auth } from "@/auth"; import { DropdownMenu, diff --git a/src/components/links/create-link.tsx b/src/components/links/create-link.tsx index f2a00fa..97cdde3 100644 --- a/src/components/links/create-link.tsx +++ b/src/components/links/create-link.tsx @@ -34,7 +34,7 @@ import { } from "@/ui/form"; import { Input, Textarea } from "@/ui/input"; import { LoaderIcon, RocketIcon, ShuffleIcon } from "lucide-react"; -import { env } from "@/env.js"; +import { env } from "@/env.mjs"; interface CreateLinkProps { children: ReactNode; diff --git a/src/server/actions/auth.ts b/src/server/actions/auth.ts index 84a51ec..9ea8206 100644 --- a/src/server/actions/auth.ts +++ b/src/server/actions/auth.ts @@ -6,7 +6,7 @@ import bcrypt from "bcryptjs"; import { AuthError } from "next-auth"; import { db } from "@/server/db"; -import { signIn, signOut } from "auth"; +import { signIn, signOut } from "@/auth"; import { getUserByEmail } from "@/server/utils/user"; import { getPasswordResetTokenByToken, diff --git a/src/server/actions/links.ts b/src/server/actions/links.ts index 60d352d..6976455 100644 --- a/src/server/actions/links.ts +++ b/src/server/actions/links.ts @@ -3,10 +3,10 @@ import type { z } from "zod"; import type { CreateLinkSchema, LinkSchema } from "@/server/schemas"; -import { auth } from "auth"; +import { auth } from "@/auth"; import { db } from "@/server/db"; import { revalidatePath } from "next/cache"; -import { env } from "@/env.js"; +import { env } from "@/env.mjs"; /** * Get links created by user. @@ -20,7 +20,7 @@ export const getLinksByUser = async () => { return null; } - const result = await db.link.findMany({ + const result = await db.links.findMany({ where: { creatorId: currentUser.user?.id, }, @@ -43,7 +43,7 @@ export const getSingleLink = async (id: number) => { return null; } - const result = await db.link.findUnique({ + const result = await db.links.findUnique({ where: { id, }, @@ -59,7 +59,7 @@ export const getSingleLink = async (id: number) => { * @type {string()} */ export const checkIfSlugExist = async (slug: string) => { - const result = await db.link.findUnique({ + const result = await db.links.findUnique({ where: { slug: slug, }, @@ -85,7 +85,7 @@ export const checkLimit = async () => { return null; } - const result = await db.link.count({ + const result = await db.links.count({ where: { creatorId: currentUser.user?.id, }, @@ -112,7 +112,7 @@ export const createLink = async (values: z.infer) => { } // Create new link: - const result = await db.link.create({ + const result = await db.links.create({ data: { ...values, creatorId: currentUser.user?.id, @@ -138,7 +138,7 @@ export const updateLink = async (values: z.infer) => { } // Update link: - const result = await db.link.update({ + const result = await db.links.update({ where: { slug: values.slug }, data: { ...values, @@ -163,7 +163,7 @@ export const deleteLink = async (id: number) => { } // Update link: - const result = await db.link.delete({ + const result = await db.links.delete({ where: { id: id, creatorId: currentUser.user?.id }, }); diff --git a/src/server/db.ts b/src/server/db.ts index 367830c..f96d438 100644 --- a/src/server/db.ts +++ b/src/server/db.ts @@ -1,7 +1,7 @@ import { PrismaClient } from "@prisma/client"; import { PrismaLibSQL } from "@prisma/adapter-libsql"; import { createClient } from "@libsql/client"; -import { env } from "@/env.js"; +import { env } from "@/env.mjs"; const globalForPrisma = globalThis as unknown as { prisma: PrismaClient | undefined; diff --git a/src/server/mail.ts b/src/server/mail.ts index 6dfe38e..3b1efe9 100644 --- a/src/server/mail.ts +++ b/src/server/mail.ts @@ -1,5 +1,5 @@ import { Resend } from "resend"; -import { env } from "@/env.js"; +import { env } from "@/env.mjs"; const resend = new Resend(env.RESEND_API_KEY);