( handler: (adminUser: utils.AdminUser, ...args: T) => Promise<NextResponse>, )
| 36 | * Higher-order function to wrap admin API routes with authentication |
| 37 | */ |
| 38 | export function withAdminAuth<T extends any[]>( |
| 39 | handler: (adminUser: utils.AdminUser, ...args: T) => Promise<NextResponse>, |
| 40 | ) { |
| 41 | return async (...args: T): Promise<NextResponse> => { |
| 42 | const authResult = await checkAdminAuth() |
| 43 | |
| 44 | if (authResult instanceof NextResponse) { |
| 45 | return authResult // Return the error response |
| 46 | } |
| 47 | |
| 48 | return handler(authResult, ...args) |
| 49 | } |
| 50 | } |
nothing calls this directly
no test coverage detected