From a3d156bdbf72a361d1cf93207960171dcc311f94 Mon Sep 17 00:00:00 2001 From: Ravinou Date: Sat, 19 Apr 2025 22:35:23 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=9A=A1=20next-auth=20does=20not?= =?UTF-8?q?=20support=20api=20versioning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/account/index.tsx | 2 +- pages/api/{v1 => }/auth/[...nextauth].ts | 0 pages/api/v1/account/email.ts | 2 +- pages/api/v1/account/password.ts | 2 +- pages/api/v1/account/username.ts | 2 +- pages/api/v1/account/wizard-env.ts | 2 +- pages/api/v1/integration/token-manager.ts | 2 +- pages/api/v1/notif/apprise/alert.ts | 2 +- pages/api/v1/notif/apprise/mode.ts | 2 +- pages/api/v1/notif/apprise/services.ts | 2 +- pages/api/v1/notif/apprise/test.ts | 2 +- pages/api/v1/notif/email/alert.ts | 2 +- pages/api/v1/notif/email/test.ts | 2 +- pages/api/v1/repositories/[slug]/index.ts | 2 +- pages/api/v1/repositories/index.ts | 2 +- pages/index.tsx | 2 +- pages/login.tsx | 2 +- pages/manage-repo/add.tsx | 2 +- pages/manage-repo/edit/[slug].tsx | 2 +- pages/monitoring/index.tsx | 2 +- pages/setup-wizard/[slug].tsx | 2 +- 21 files changed, 20 insertions(+), 20 deletions(-) rename pages/api/{v1 => }/auth/[...nextauth].ts (100%) diff --git a/pages/account/index.tsx b/pages/account/index.tsx index 84a29e4..000b4a6 100644 --- a/pages/account/index.tsx +++ b/pages/account/index.tsx @@ -1,7 +1,7 @@ import Head from 'next/head'; import 'react-toastify/dist/ReactToastify.css'; import { useSession } from 'next-auth/react'; -import { authOptions } from '../api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { GetServerSidePropsContext } from 'next'; import { SessionStatus } from '~/types'; diff --git a/pages/api/v1/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].ts similarity index 100% rename from pages/api/v1/auth/[...nextauth].ts rename to pages/api/auth/[...nextauth].ts diff --git a/pages/api/v1/account/email.ts b/pages/api/v1/account/email.ts index bfc9e7a..4033122 100644 --- a/pages/api/v1/account/email.ts +++ b/pages/api/v1/account/email.ts @@ -1,5 +1,5 @@ import { ConfigService } from '~/services'; -import { authOptions } from '../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; import { EmailSettingDTO, ErrorResponse } from '~/types'; diff --git a/pages/api/v1/account/password.ts b/pages/api/v1/account/password.ts index 55fbe24..015e3c6 100644 --- a/pages/api/v1/account/password.ts +++ b/pages/api/v1/account/password.ts @@ -1,4 +1,4 @@ -import { authOptions } from '../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { ConfigService, AuthService } from '~/services'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; diff --git a/pages/api/v1/account/username.ts b/pages/api/v1/account/username.ts index c2ff2e3..3d1ffaf 100644 --- a/pages/api/v1/account/username.ts +++ b/pages/api/v1/account/username.ts @@ -1,5 +1,5 @@ import { ConfigService } from '~/services'; -import { authOptions } from '../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; import { ErrorResponse, UsernameSettingDTO } from '~/types'; diff --git a/pages/api/v1/account/wizard-env.ts b/pages/api/v1/account/wizard-env.ts index 7fdd03b..548aebf 100644 --- a/pages/api/v1/account/wizard-env.ts +++ b/pages/api/v1/account/wizard-env.ts @@ -1,4 +1,4 @@ -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; import { ErrorResponse, WizardEnvEnum, WizardEnvType } from '~/types'; diff --git a/pages/api/v1/integration/token-manager.ts b/pages/api/v1/integration/token-manager.ts index 9b8a615..205c15b 100644 --- a/pages/api/v1/integration/token-manager.ts +++ b/pages/api/v1/integration/token-manager.ts @@ -1,4 +1,4 @@ -import { authOptions } from '../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; import ApiResponse from '~/helpers/functions/apiResponse'; diff --git a/pages/api/v1/notif/apprise/alert.ts b/pages/api/v1/notif/apprise/alert.ts index 22d4a40..b0a5fe8 100644 --- a/pages/api/v1/notif/apprise/alert.ts +++ b/pages/api/v1/notif/apprise/alert.ts @@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { getServerSession } from 'next-auth/next'; import { ConfigService } from '~/services'; import { ErrorResponse, AppriseAlertResponse } from '~/types'; -import { authOptions } from '../../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import ApiResponse from '~/helpers/functions/apiResponse'; export default async function handler( diff --git a/pages/api/v1/notif/apprise/mode.ts b/pages/api/v1/notif/apprise/mode.ts index f35d76e..4223390 100644 --- a/pages/api/v1/notif/apprise/mode.ts +++ b/pages/api/v1/notif/apprise/mode.ts @@ -1,7 +1,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { getServerSession } from 'next-auth/next'; import { ConfigService } from '~/services'; -import { authOptions } from '../../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { AppriseModeDTO, ErrorResponse } from '~/types'; import ApiResponse from '~/helpers/functions/apiResponse'; diff --git a/pages/api/v1/notif/apprise/services.ts b/pages/api/v1/notif/apprise/services.ts index 5848d2a..7b13971 100644 --- a/pages/api/v1/notif/apprise/services.ts +++ b/pages/api/v1/notif/apprise/services.ts @@ -1,7 +1,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { getServerSession } from 'next-auth/next'; import { ConfigService } from '~/services'; -import { authOptions } from '../../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { AppriseServicesDTO, ErrorResponse } from '~/types'; import ApiResponse from '~/helpers/functions/apiResponse'; diff --git a/pages/api/v1/notif/apprise/test.ts b/pages/api/v1/notif/apprise/test.ts index 0b5d7f7..b38be51 100644 --- a/pages/api/v1/notif/apprise/test.ts +++ b/pages/api/v1/notif/apprise/test.ts @@ -4,7 +4,7 @@ import { getServerSession } from 'next-auth/next'; import { promisify } from 'util'; import { ConfigService } from '~/services'; import { ErrorResponse, SuccessResponse } from '~/types'; -import { authOptions } from '../../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; const execAsync = promisify(exec); diff --git a/pages/api/v1/notif/email/alert.ts b/pages/api/v1/notif/email/alert.ts index 74d532f..c1e4937 100644 --- a/pages/api/v1/notif/email/alert.ts +++ b/pages/api/v1/notif/email/alert.ts @@ -1,7 +1,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { getServerSession } from 'next-auth/next'; import { ConfigService } from '~/services'; -import { authOptions } from '../../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { EmailAlertDTO, ErrorResponse } from '~/types'; import ApiResponse from '~/helpers/functions/apiResponse'; diff --git a/pages/api/v1/notif/email/test.ts b/pages/api/v1/notif/email/test.ts index 9beed9e..a4c78a9 100644 --- a/pages/api/v1/notif/email/test.ts +++ b/pages/api/v1/notif/email/test.ts @@ -1,4 +1,4 @@ -import { authOptions } from '../../auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; import emailTest from '~/helpers/templates/emailTest'; diff --git a/pages/api/v1/repositories/[slug]/index.ts b/pages/api/v1/repositories/[slug]/index.ts index 8d1f486..d4f693b 100644 --- a/pages/api/v1/repositories/[slug]/index.ts +++ b/pages/api/v1/repositories/[slug]/index.ts @@ -1,4 +1,4 @@ -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; import { BorgWarehouseApiResponse, Repository } from '~/types'; diff --git a/pages/api/v1/repositories/index.ts b/pages/api/v1/repositories/index.ts index de47673..b87e3e3 100644 --- a/pages/api/v1/repositories/index.ts +++ b/pages/api/v1/repositories/index.ts @@ -1,4 +1,4 @@ -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { NextApiRequest, NextApiResponse } from 'next'; import { BorgWarehouseApiResponse, Repository } from '~/types'; diff --git a/pages/index.tsx b/pages/index.tsx index 7e82143..6d826ae 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,4 +1,4 @@ -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { useSession } from 'next-auth/react'; import Head from 'next/head'; diff --git a/pages/login.tsx b/pages/login.tsx index 05ab092..5c31337 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -5,7 +5,7 @@ import { useEffect } from 'react'; import { useForm } from 'react-hook-form'; import { SpinnerDotted } from 'spinners-react'; import { useFormStatus } from '~/hooks'; -import { authOptions } from './api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; //Components import { GetServerSidePropsContext } from 'next'; diff --git a/pages/manage-repo/add.tsx b/pages/manage-repo/add.tsx index b102568..9435261 100644 --- a/pages/manage-repo/add.tsx +++ b/pages/manage-repo/add.tsx @@ -1,6 +1,6 @@ import { GetServerSidePropsContext } from 'next'; import RepoList from '~/Containers/RepoList/RepoList'; -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; export default function Add() { diff --git a/pages/manage-repo/edit/[slug].tsx b/pages/manage-repo/edit/[slug].tsx index b102568..9435261 100644 --- a/pages/manage-repo/edit/[slug].tsx +++ b/pages/manage-repo/edit/[slug].tsx @@ -1,6 +1,6 @@ import { GetServerSidePropsContext } from 'next'; import RepoList from '~/Containers/RepoList/RepoList'; -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; export default function Add() { diff --git a/pages/monitoring/index.tsx b/pages/monitoring/index.tsx index 6ddd40f..216caf5 100644 --- a/pages/monitoring/index.tsx +++ b/pages/monitoring/index.tsx @@ -1,5 +1,5 @@ import Head from 'next/head'; -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { GetServerSidePropsContext } from 'next'; diff --git a/pages/setup-wizard/[slug].tsx b/pages/setup-wizard/[slug].tsx index 671dbbd..b8687bc 100644 --- a/pages/setup-wizard/[slug].tsx +++ b/pages/setup-wizard/[slug].tsx @@ -1,7 +1,7 @@ import SetupWizard from '../../Containers/SetupWizard/SetupWizard'; import { useRouter } from 'next/router'; import Head from 'next/head'; -import { authOptions } from '~/pages/api/v1/auth/[...nextauth]'; +import { authOptions } from '~/pages/api/auth/[...nextauth]'; import { getServerSession } from 'next-auth/next'; import { GetServerSidePropsContext } from 'next';