test(docs): trace production runtime verification
Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>
This commit is contained in:
committed by
Junior Garcia
parent
8bc427b7db
commit
ed0f3a63c5
@@ -1,6 +1,31 @@
|
||||
import {createEnv} from "@t3-oss/env-nextjs";
|
||||
import {z} from "zod";
|
||||
|
||||
// #region agent log
|
||||
if (typeof window === "undefined") {
|
||||
const fileSystem = process.getBuiltinModule("fs") as {
|
||||
appendFileSync(path: string, data: string): void;
|
||||
};
|
||||
|
||||
fileSystem.appendFileSync(
|
||||
"/opt/cursor/logs/debug.log",
|
||||
`${JSON.stringify({
|
||||
data: {
|
||||
featurebaseEndpointPresent: process.env["FEATUREBASE_API_ENDPOINT"] !== undefined,
|
||||
featurebaseKeyPresent: process.env["FEATUREBASE_API_KEY"] !== undefined,
|
||||
loopsEndpointPresent: process.env["LOOPS_API_ENDPOINT"] !== undefined,
|
||||
loopsKeyPresent: process.env["LOOPS_API_KEY"] !== undefined,
|
||||
nodeEnv: process.env["NODE_ENV"] ?? null,
|
||||
},
|
||||
hypothesisId: "D",
|
||||
location: "apps/docs/env.ts:module-evaluation",
|
||||
message: "Validating documentation runtime environment",
|
||||
timestamp: Date.now(),
|
||||
})}\n`,
|
||||
);
|
||||
}
|
||||
// #endregion
|
||||
|
||||
export const env = createEnv({
|
||||
client: {
|
||||
NEXT_PUBLIC_APP_ENV: z.enum(["production", "preview", "development"]).default("development"),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type {NextRequest} from "next/server";
|
||||
|
||||
import {appendFileSync} from "node:fs";
|
||||
|
||||
import {notFound} from "next/navigation";
|
||||
import {NextResponse} from "next/server";
|
||||
|
||||
@@ -24,7 +26,22 @@ function extractLangFromSlug(slug: string[]): {slug: string[]; lang?: string} {
|
||||
}
|
||||
|
||||
export async function GET(_req: NextRequest, {params}: {params: Promise<{slug: string[]}>}) {
|
||||
const {lang, slug} = extractLangFromSlug((await params).slug);
|
||||
const routeParams = await params;
|
||||
|
||||
// #region agent log
|
||||
appendFileSync(
|
||||
"/opt/cursor/logs/debug.log",
|
||||
`${JSON.stringify({
|
||||
data: {routeSlug: routeParams.slug},
|
||||
hypothesisId: "C,D",
|
||||
location: "apps/docs/src/app/llms.mdx/[...slug]/route.ts:GET-entry",
|
||||
message: "MDX route handler entered",
|
||||
timestamp: Date.now(),
|
||||
})}\n`,
|
||||
);
|
||||
// #endregion
|
||||
|
||||
const {lang, slug} = extractLangFromSlug(routeParams.slug);
|
||||
const page = source.getPage(slug, lang);
|
||||
|
||||
if (!page) notFound();
|
||||
@@ -32,6 +49,19 @@ export async function GET(_req: NextRequest, {params}: {params: Promise<{slug: s
|
||||
try {
|
||||
const content = await getLLMText(page);
|
||||
|
||||
// #region agent log
|
||||
appendFileSync(
|
||||
"/opt/cursor/logs/debug.log",
|
||||
`${JSON.stringify({
|
||||
data: {contentLength: content.length, lang: lang ?? null, slug},
|
||||
hypothesisId: "D,E",
|
||||
location: "apps/docs/src/app/llms.mdx/[...slug]/route.ts:GET-exit",
|
||||
message: "Generated MDX response",
|
||||
timestamp: Date.now(),
|
||||
})}\n`,
|
||||
);
|
||||
// #endregion
|
||||
|
||||
return new NextResponse(content, {
|
||||
headers: LLMS_TEXT_HEADERS,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user