From d0d8e6ba1804d0c0a5183979dc008c8faf9117e6 Mon Sep 17 00:00:00 2001 From: Moinul Moin Date: Sat, 23 Nov 2024 14:59:46 +0600 Subject: [PATCH 1/2] refactor: :recycle: improve file, folder structure --- package.json | 1 - pnpm-lock.yaml | 18 ------------------ src/actions/auth.ts | 7 +++---- src/actions/mail.ts | 2 +- src/actions/subscription.ts | 2 +- src/app/[locale]/{ => (auth)}/login/page.tsx | 2 +- .../[locale]/{ => (marketing)}/about/page.tsx | 2 +- .../{ => (marketing)}/changelog/page.tsx | 4 ++-- .../[locale]/@loginDialog/(.)login/page.tsx | 2 +- src/app/[locale]/dashboard/billing/page.tsx | 4 ++-- src/app/[locale]/dashboard/layout.tsx | 2 +- src/app/[locale]/dashboard/projects/action.ts | 4 ++-- src/app/[locale]/dashboard/settings/actions.ts | 6 +++--- src/app/[locale]/dashboard/settings/page.tsx | 2 +- src/app/[locale]/layout.tsx | 4 ++-- .../api/auth/login/github/callback/route.ts | 8 ++++---- src/app/api/auth/login/github/route.ts | 2 +- src/app/api/auth/login/send-otp/route.ts | 2 +- src/app/api/auth/login/verify-otp/route.ts | 6 +++--- src/app/api/stripe/route.ts | 4 ++-- src/app/api/uploadthing/core.ts | 2 +- src/app/api/webhooks/stripe/route.ts | 4 ++-- src/components/layout/header/index.tsx | 4 ++-- src/components/layout/image-upload-modal.tsx | 2 +- src/components/sections/pricing.tsx | 2 +- src/lib/{ => client}/uploadthing.ts | 0 src/lib/{ => server}/cookies.ts | 0 src/lib/{ => server}/github.ts | 0 src/lib/{ => server}/prisma.ts | 0 src/lib/{ => server}/resend.ts | 0 src/lib/{ => server}/session.ts | 0 src/lib/{ => server}/stripe.ts | 0 .../uploadthing.ts} | 0 src/types/lucia.d.ts | 13 ------------- 34 files changed, 39 insertions(+), 72 deletions(-) rename src/app/[locale]/{ => (auth)}/login/page.tsx (92%) rename src/app/[locale]/{ => (marketing)}/about/page.tsx (97%) rename src/app/[locale]/{ => (marketing)}/changelog/page.tsx (87%) rename src/lib/{ => client}/uploadthing.ts (100%) rename src/lib/{ => server}/cookies.ts (100%) rename src/lib/{ => server}/github.ts (100%) rename src/lib/{ => server}/prisma.ts (100%) rename src/lib/{ => server}/resend.ts (100%) rename src/lib/{ => server}/session.ts (100%) rename src/lib/{ => server}/stripe.ts (100%) rename src/lib/{uploadthing-server.ts => server/uploadthing.ts} (100%) delete mode 100644 src/types/lucia.d.ts diff --git a/package.json b/package.json index 3409b9c..67a8b40 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "autoprefixer": "10.4.20", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", - "encoding": "^0.1.13", "eslint": "8.56.0", "eslint-config-next": "15.0.3", "eslint-config-prettier": "^8.10.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd42042..592ff54 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,9 +138,6 @@ importers: clsx: specifier: ^2.1.1 version: 2.1.1 - encoding: - specifier: ^0.1.13 - version: 0.1.13 eslint: specifier: 8.56.0 version: 8.56.0 @@ -2670,9 +2667,6 @@ packages: emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} - encoding@0.1.13: - resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} - engine.io-parser@5.2.3: resolution: {integrity: sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==} engines: {node: '>=10.0.0'} @@ -3229,10 +3223,6 @@ packages: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} - iconv-lite@0.6.3: - resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} - engines: {node: '>=0.10.0'} - idb@8.0.0: resolution: {integrity: sha512-l//qvlAKGmQO31Qn7xdzagVPPaHTxXx199MhrAFuVBTPqydcPYBWjkrbv4Y0ktB+GmWOiwHl237UUOrLmQxLvw==} @@ -7746,10 +7736,6 @@ snapshots: emoji-regex@9.2.2: {} - encoding@0.1.13: - dependencies: - iconv-lite: 0.6.3 - engine.io-parser@5.2.3: {} engine.io@6.6.2: @@ -8640,10 +8626,6 @@ snapshots: dependencies: safer-buffer: 2.1.2 - iconv-lite@0.6.3: - dependencies: - safer-buffer: 2.1.2 - idb@8.0.0: {} ieee754@1.2.1: {} diff --git a/src/actions/auth.ts b/src/actions/auth.ts index 52ff450..84548aa 100644 --- a/src/actions/auth.ts +++ b/src/actions/auth.ts @@ -3,13 +3,12 @@ import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { alphabet, generateRandomString } from "oslo/crypto"; -import { deleteSessionTokenCookie } from "~/lib/cookies"; -import prisma from "~/lib/prisma"; -import { getCurrentSession, invalidateSession } from "~/lib/session"; +import { deleteSessionTokenCookie } from "~/lib/server/cookies"; +import prisma from "~/lib/server/prisma"; +import { getCurrentSession, invalidateSession } from "~/lib/server/session"; export async function logout() { const { session } = await getCurrentSession(); - if (!session) { return { message: "Unauthorized", diff --git a/src/actions/mail.ts b/src/actions/mail.ts index d08a504..7b07ccf 100644 --- a/src/actions/mail.ts +++ b/src/actions/mail.ts @@ -3,7 +3,7 @@ import ThanksTemp from "emails/thanks"; import VerificationTemp from "emails/verification"; import { nanoid } from "nanoid"; -import { resend } from "~/lib/resend"; +import { resend } from "~/lib/server/resend"; import { type SendOTPProps, type SendWelcomeEmailProps } from "~/types"; export const sendWelcomeEmail = async ({ diff --git a/src/actions/subscription.ts b/src/actions/subscription.ts index 9654d1d..b93b4ea 100644 --- a/src/actions/subscription.ts +++ b/src/actions/subscription.ts @@ -1,7 +1,7 @@ "use server"; import { freePlan, proPlan } from "~/config/subscription"; -import prisma from "~/lib/prisma"; +import prisma from "~/lib/server/prisma"; import { type UserSubscriptionPlan } from "~/types"; export async function getUserSubscriptionPlan( diff --git a/src/app/[locale]/login/page.tsx b/src/app/[locale]/(auth)/login/page.tsx similarity index 92% rename from src/app/[locale]/login/page.tsx rename to src/app/[locale]/(auth)/login/page.tsx index cd515d2..e3abbf6 100644 --- a/src/app/[locale]/login/page.tsx +++ b/src/app/[locale]/(auth)/login/page.tsx @@ -1,7 +1,7 @@ import { redirect } from "next/navigation"; import AuthForm from "~/components/layout/auth-form"; import { Card } from "~/components/ui/card"; -import { getCurrentSession } from "~/lib/session"; +import { getCurrentSession } from "~/lib/server/session"; export default async function Login() { const { session } = await getCurrentSession(); diff --git a/src/app/[locale]/about/page.tsx b/src/app/[locale]/(marketing)/about/page.tsx similarity index 97% rename from src/app/[locale]/about/page.tsx rename to src/app/[locale]/(marketing)/about/page.tsx index b2af27d..6f8484b 100644 --- a/src/app/[locale]/about/page.tsx +++ b/src/app/[locale]/(marketing)/about/page.tsx @@ -4,7 +4,7 @@ import { type Metadata } from "next"; function AboutCard(about: About) { return (
-

+

{about.title}

diff --git a/src/app/[locale]/changelog/page.tsx b/src/app/[locale]/(marketing)/changelog/page.tsx similarity index 87% rename from src/app/[locale]/changelog/page.tsx rename to src/app/[locale]/(marketing)/changelog/page.tsx index 315e6f2..285a166 100644 --- a/src/app/[locale]/changelog/page.tsx +++ b/src/app/[locale]/(marketing)/changelog/page.tsx @@ -5,10 +5,10 @@ import { type Metadata } from "next"; function ChangeCard(change: Change) { return (
-

+

{change.title}

-