diff --git a/apps/quartz-app/app/api/auth/[auth0]/route.ts b/apps/quartz-app/app/api/auth/[auth0]/route.ts index 9e522ef4..3e0285a2 100644 --- a/apps/quartz-app/app/api/auth/[auth0]/route.ts +++ b/apps/quartz-app/app/api/auth/[auth0]/route.ts @@ -1,5 +1,12 @@ -import { handleAuth, handleLogout } from "@auth0/nextjs-auth0"; +import { handleAuth, handleLogout, HandleAuth } from "@auth0/nextjs-auth0"; +/** + * This is a GET endpoint that automatically handles authentication using Auth0. + * We're using a logout option override to redirect to "/logout" after logout. + * + * @function GET + * @returns {HandleAuth} A function that handles authentication. + */ export const GET = handleAuth({ logout: handleLogout({ returnTo: "/logout", diff --git a/apps/quartz-app/app/api/token/route.ts b/apps/quartz-app/app/api/token/route.ts index 1eeae9b3..d2603482 100644 --- a/apps/quartz-app/app/api/token/route.ts +++ b/apps/quartz-app/app/api/token/route.ts @@ -1,7 +1,16 @@ -import { NextResponse } from "next/server"; +import { NextRequest, NextResponse } from "next/server"; import { getAccessToken, withApiAuthRequired } from "@auth0/nextjs-auth0"; -const GET = withApiAuthRequired(async function GET(req) { +/** + * This is a secured GET endpoint that requires API authentication. + * It retrieves the access token for the authenticated user. + * + * @async + * @function GET + * @param {NextRequest} req - The Next.js API request object. + * @returns {NextResponse} A JSON response containing the access token. + */ +const GET = withApiAuthRequired(async function GET(req: NextRequest) { const res = new NextResponse(); const { accessToken } = await getAccessToken(req, res); return NextResponse.json({ accessToken }, res);