MCPcopy
hub / github.com/simstudioai/sim / withAdminAuthParams

Function withAdminAuthParams

apps/sim/app/api/v1/admin/middleware.ts:35–50  ·  view source on GitHub ↗
(
  handler: AdminRouteHandlerWithParams<TParams>
)

Source from the content-addressed store, hash-verified

33 * Returns early with an error response if authentication fails.
34 */
35export function withAdminAuthParams<TParams>(
36 handler: AdminRouteHandlerWithParams<TParams>
37): AdminRouteHandlerWithParams<TParams> {
38 return async (request: NextRequest, context: { params: Promise<TParams> }) => {
39 const auth = authenticateAdminRequest(request)
40
41 if (!auth.authenticated) {
42 if (auth.notConfigured) {
43 return notConfiguredResponse()
44 }
45 return unauthorizedResponse(auth.error)
46 }
47
48 return handler(request, context)
49 }
50}

Callers 15

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 4

authenticateAdminRequestFunction · 0.90
notConfiguredResponseFunction · 0.90
unauthorizedResponseFunction · 0.90
handlerFunction · 0.50

Tested by

no test coverage detected