Skip to content

Commit

Permalink
add tsdoc comments to auth functions
Browse files Browse the repository at this point in the history
  • Loading branch information
braddf committed May 30, 2024
1 parent 5822dd4 commit 1760204
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion apps/quartz-app/app/api/auth/[auth0]/route.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 11 additions & 2 deletions apps/quartz-app/app/api/token/route.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 1760204

Please sign in to comment.