style: apply code formatting to generated templates and TypeScript files
- Regenerate Go template files with updated FileName paths for error reporting - Apply Prettier formatting to api-explorer-docs.ts for consistency - Format long function signatures across multiple lines for readability - Format long conditional chains for better code clarity Changes are purely formatting and do not affect functionality: - api-explorer-docs.ts: Format initAPIExplorerDoc, tryDocEndpoint, and other functions - Generated _templ.go files: Update FileName paths from relative to absolute (e.g., "admin.templ" → "templates/admin.templ") This ensures consistent code style across the codebase and improves error reporting by providing full file paths in template error messages.
This commit is contained in:
@@ -4,7 +4,11 @@ import { getToken } from "./storage";
|
||||
let endpointPath = "";
|
||||
let exampleResponse: unknown = null;
|
||||
|
||||
function initAPIExplorerDoc(path: string, request: string, response: string): void {
|
||||
function initAPIExplorerDoc(
|
||||
path: string,
|
||||
request: string,
|
||||
response: string,
|
||||
): void {
|
||||
endpointPath = path;
|
||||
exampleResponse = JSON.parse(response);
|
||||
}
|
||||
@@ -16,10 +20,22 @@ function showDocMode(mode: "mock" | "real"): void {
|
||||
const responseStatus = document.getElementById("response-status");
|
||||
const responseTime = document.getElementById("response-time");
|
||||
const apiResponse = document.querySelector(".api-response");
|
||||
const requestBody = document.getElementById("request-body") as HTMLTextAreaElement;
|
||||
const requestBody = document.getElementById(
|
||||
"request-body",
|
||||
) as HTMLTextAreaElement;
|
||||
const tryItOut = document.getElementById("try-it-out");
|
||||
|
||||
if (!mockBtn || !realBtn || !responseBody || !responseStatus || !responseTime || !apiResponse || !requestBody || !tryItOut) return;
|
||||
if (
|
||||
!mockBtn ||
|
||||
!realBtn ||
|
||||
!responseBody ||
|
||||
!responseStatus ||
|
||||
!responseTime ||
|
||||
!apiResponse ||
|
||||
!requestBody ||
|
||||
!tryItOut
|
||||
)
|
||||
return;
|
||||
|
||||
if (mode === "mock") {
|
||||
mockBtn.classList.add("bg-accent", "text-white");
|
||||
@@ -46,14 +62,26 @@ function showDocMode(mode: "mock" | "real"): void {
|
||||
}
|
||||
|
||||
async function tryDocEndpoint(): Promise<void> {
|
||||
const methodSelect = document.getElementById("http-method") as HTMLSelectElement;
|
||||
const requestBody = document.getElementById("request-body") as HTMLTextAreaElement;
|
||||
const methodSelect = document.getElementById(
|
||||
"http-method",
|
||||
) as HTMLSelectElement;
|
||||
const requestBody = document.getElementById(
|
||||
"request-body",
|
||||
) as HTMLTextAreaElement;
|
||||
const responseBody = document.getElementById("response-body");
|
||||
const responseStatus = document.getElementById("response-status");
|
||||
const responseTime = document.getElementById("response-time");
|
||||
const apiResponse = document.querySelector(".api-response");
|
||||
|
||||
if (!methodSelect || !requestBody || !responseBody || !responseStatus || !responseTime || !apiResponse) return;
|
||||
if (
|
||||
!methodSelect ||
|
||||
!requestBody ||
|
||||
!responseBody ||
|
||||
!responseStatus ||
|
||||
!responseTime ||
|
||||
!apiResponse
|
||||
)
|
||||
return;
|
||||
|
||||
const method = methodSelect.value;
|
||||
const body = requestBody.value;
|
||||
@@ -89,7 +117,9 @@ async function tryDocEndpoint(): Promise<void> {
|
||||
}
|
||||
|
||||
function copyDocRequest(): void {
|
||||
const requestBody = document.getElementById("request-body") as HTMLTextAreaElement;
|
||||
const requestBody = document.getElementById(
|
||||
"request-body",
|
||||
) as HTMLTextAreaElement;
|
||||
if (requestBody) {
|
||||
navigator.clipboard.writeText(requestBody.value);
|
||||
}
|
||||
@@ -103,8 +133,12 @@ function copyDocResponse(): void {
|
||||
}
|
||||
|
||||
function generateDocCURL(): void {
|
||||
const methodSelect = document.getElementById("http-method") as HTMLSelectElement;
|
||||
const requestBody = document.getElementById("request-body") as HTMLTextAreaElement;
|
||||
const methodSelect = document.getElementById(
|
||||
"http-method",
|
||||
) as HTMLSelectElement;
|
||||
const requestBody = document.getElementById(
|
||||
"request-body",
|
||||
) as HTMLTextAreaElement;
|
||||
|
||||
if (!methodSelect || !requestBody) return;
|
||||
|
||||
@@ -132,11 +166,11 @@ export {
|
||||
tryDocEndpoint,
|
||||
};
|
||||
|
||||
Alpine.store("apiExplorerDoc", {
|
||||
Alpine.data("apiExplorerDoc", () => ({
|
||||
copyDocRequest,
|
||||
copyDocResponse,
|
||||
generateDocCURL,
|
||||
initAPIExplorerDoc,
|
||||
showDocMode,
|
||||
tryDocEndpoint,
|
||||
});
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user