Skip to content

Commit ba2f2aa

Browse files
committed
chore: add examples to types
1 parent 9e80ec4 commit ba2f2aa

File tree

1 file changed

+16
-0
lines changed
  • packages/nextjs/src/app-router/server

1 file changed

+16
-0
lines changed

packages/nextjs/src/app-router/server/auth.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,32 @@ type MachineAuth<T extends TokenType> = (AuthenticatedMachineObject | Unauthenti
5454
export type AuthOptions = { acceptsToken?: TokenType | TokenType[] | 'any' };
5555

5656
export interface AuthFn<TRedirect = ReturnType<typeof redirect>> {
57+
/**
58+
* @example
59+
* const authObject = await auth({ acceptsToken: ['session_token', 'api_key'] })
60+
*/
5761
<T extends TokenType[]>(
5862
options: AuthOptions & { acceptsToken: T },
5963
): Promise<InferAuthObjectFromTokenArray<T, SessionAuth<TRedirect>, MachineAuth<T[number]>>>;
6064

65+
/**
66+
* @example
67+
* const authObject = await auth({ acceptsToken: 'session_token' })
68+
*/
6169
<T extends TokenType>(
6270
options: AuthOptions & { acceptsToken: T },
6371
): Promise<InferAuthObjectFromToken<T, SessionAuth<TRedirect>, MachineAuth<T>>>;
6472

73+
/**
74+
* @example
75+
* const authObject = await auth({ acceptsToken: 'any' })
76+
*/
6577
(options: AuthOptions & { acceptsToken: 'any' }): Promise<AuthObject>;
6678

79+
/**
80+
* @example
81+
* const authObject = await auth()
82+
*/
6783
(): Promise<SessionAuth<TRedirect>>;
6884

6985
/**

0 commit comments

Comments
 (0)