mirror of
https://github.com/fergalmoran/kidarr-server.git
synced 2025-12-29 04:50:39 +00:00
Add debug page
This commit is contained in:
15
src/app/(debug)/debug/page.tsx
Normal file
15
src/app/(debug)/debug/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import PrintEnv from "@/components/widgets/print-env";
|
||||||
|
import { authOptions } from "@/server/auth";
|
||||||
|
import { getServerSession } from "next-auth";
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
|
||||||
|
const DebugPage = async () => {
|
||||||
|
const session = await getServerSession(authOptions);
|
||||||
|
const request = headers();
|
||||||
|
return (
|
||||||
|
<div className="p-6">
|
||||||
|
<PrintEnv session={null} request={request} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default DebugPage;
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import QRCode from 'react-qr-code';
|
|
||||||
|
|
||||||
const DebugPage = () => {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<QRCode value="7506" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export default DebugPage;
|
|
||||||
19
src/components/widgets/print-env.tsx
Normal file
19
src/components/widgets/print-env.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { type Session } from "next-auth";
|
||||||
|
import { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
|
||||||
|
import React from "react";
|
||||||
|
import { env } from "@/env";
|
||||||
|
type PrintEnvProps = {
|
||||||
|
session: Session | null;
|
||||||
|
request: ReadonlyHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
const PrintEnv: React.FC<PrintEnvProps> = ({ session, request }) => {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col space-x-4">
|
||||||
|
<div>{JSON.stringify(session, null, 2)}</div>
|
||||||
|
<div>{JSON.stringify(request, null, 2)}</div>
|
||||||
|
<div>{JSON.stringify(env, null, 2)}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default PrintEnv;
|
||||||
30
src/lib/helpers/debug.ts
Normal file
30
src/lib/helpers/debug.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||||
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
|
export function syntaxHighlight(json) {
|
||||||
|
if (typeof json != "string") {
|
||||||
|
json = JSON.stringify(json, undefined, 2);
|
||||||
|
}
|
||||||
|
json = json
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">");
|
||||||
|
return json.replace(
|
||||||
|
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
|
||||||
|
function (match) {
|
||||||
|
var cls = "number";
|
||||||
|
if (/^"/.test(match)) {
|
||||||
|
if (/:$/.test(match)) {
|
||||||
|
cls = "key";
|
||||||
|
} else {
|
||||||
|
cls = "string";
|
||||||
|
}
|
||||||
|
} else if (/true|false/.test(match)) {
|
||||||
|
cls = "boolean";
|
||||||
|
} else if (/null/.test(match)) {
|
||||||
|
cls = "null";
|
||||||
|
}
|
||||||
|
return '<span class="' + cls + '">' + match + "</span>";
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user