From 8692eee0df682e62370ad7af2def1e189ba04ea3 Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Fri, 19 Dec 2025 15:31:01 -0500 Subject: [PATCH] protected --- src/routes/test.tsx | 545 +++++++++++++++++++++++--------------------- 1 file changed, 287 insertions(+), 258 deletions(-) diff --git a/src/routes/test.tsx b/src/routes/test.tsx index 2f14b27..56a90e0 100644 --- a/src/routes/test.tsx +++ b/src/routes/test.tsx @@ -1,6 +1,18 @@ import { createSignal, For, Show } from "solid-js"; +import { query, createAsync } from "@solidjs/router"; +import { getRequestEvent } from "solid-js/web"; +import { getPrivilegeLevel } from "~/server/utils"; import { api } from "~/lib/api"; +const getAuthState = query(async () => { + "use server"; + + const event = getRequestEvent()!; + const privilegeLevel = await getPrivilegeLevel(event.nativeEvent); + + return { privilegeLevel }; +}, "test-auth-state"); + type EndpointTest = { name: string; router: string; @@ -846,6 +858,8 @@ const routerSections: RouterSection[] = [ ]; export default function TestPage() { + const authState = createAsync(() => getAuthState()); + const [expandedSections, setExpandedSections] = createSignal>( new Set() ); @@ -919,282 +933,297 @@ export default function TestPage() { }; return ( -
-
-
-

tRPC API Testing Dashboard

-

- Complete API coverage: Example, Auth, Database, User, Misc, and - Lineage routers -

- -
-

- Quick Start: Expand any section below to test - endpoints. Public endpoints work immediately. Auth-required - endpoints need valid tokens. + +

Unauthorized
+
+ You must be an admin to access this page. +
+
+ } + > +
+
+
+

tRPC API Testing Dashboard

+

+ Complete API coverage: Example, Auth, Database, User, Misc, and + Lineage routers

+ +
+

+ Quick Start: Expand any section below to test + endpoints. Public endpoints work immediately. Auth-required + endpoints need valid tokens. +

+
-
-
- - {(section) => { - const isExpanded = () => expandedSections().has(section.name); +
+ + {(section) => { + const isExpanded = () => expandedSections().has(section.name); - return ( -
- {/* Section Header */} - + return ( +
+ {/* Section Header */} + - {/* Section Content */} - -
- - {(endpoint) => { - const key = `${endpoint.router}.${endpoint.procedure}`; - const hasInput = endpoint.sampleInput !== undefined; - const displayInput = () => { - if (inputEdits()[key]) { - return inputEdits()[key]; - } - // Handle primitive values (string, number, boolean) - if (typeof endpoint.sampleInput === "string") { - return `"${endpoint.sampleInput}"`; - } - if ( - typeof endpoint.sampleInput === "number" || - typeof endpoint.sampleInput === "boolean" - ) { - return String(endpoint.sampleInput); - } - // Handle objects and arrays - return JSON.stringify( - endpoint.sampleInput, - null, - 2 - ); - }; + {/* Section Content */} + +
+ + {(endpoint) => { + const key = `${endpoint.router}.${endpoint.procedure}`; + const hasInput = endpoint.sampleInput !== undefined; + const displayInput = () => { + if (inputEdits()[key]) { + return inputEdits()[key]; + } + // Handle primitive values (string, number, boolean) + if (typeof endpoint.sampleInput === "string") { + return `"${endpoint.sampleInput}"`; + } + if ( + typeof endpoint.sampleInput === "number" || + typeof endpoint.sampleInput === "boolean" + ) { + return String(endpoint.sampleInput); + } + // Handle objects and arrays + return JSON.stringify( + endpoint.sampleInput, + null, + 2 + ); + }; - return ( -
- {/* Endpoint Header */} -
-
-
-

- {endpoint.name} -

- - - 🔒 Auth Required + return ( +
+ {/* Endpoint Header */} +
+
+
+

+ {endpoint.name} +

+ + + 🔒 Auth Required + + + + + 👑 Admin Only + + +
+

+ {endpoint.description} +

+
+ + {key} + + + {endpoint.method === "query" + ? "GET" + : "POST"} - - - - 👑 Admin Only - - -
-

- {endpoint.description} -

-
- - {key} - - - {endpoint.method === "query" - ? "GET" - : "POST"} - +
+
- + + {/* Input Editor */} + +
+ +