Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/app/api/debug/content-paths/route.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/app/api/debug/content-paths/route.ts |
| Original SHA-256 | 4359edbea3109e1b9b7cd564aaf0bda920ad3177f5454e26c438d8103dbdb43d |
| Git blob SHA | a6c097af6c4de2ef00aa809c2d86284788075345 |
| Reading-copy SHA-256 | 4359edbea3109e1b9b7cd564aaf0bda920ad3177f5454e26c438d8103dbdb43d |
Recovered source transcript
Download complete source text ↓59 lines · 1.7 KB
import fs from 'node:fs'
import path from 'node:path'
import { type NextRequest, NextResponse } from 'next/server'
import { ensureDebugAccess } from '@/app/api/debug/_utils'
/**
* Endpoint to check content paths and debug content-collections issues
*/
export async function GET(_request: NextRequest) {
const access = await ensureDebugAccess(_request)
if (!access.ok) {
return access.response
}
const paths = {
cwd: process.cwd(),
relPath: path.resolve(process.cwd(), '../../packages/content/data'),
absPath: path.resolve(process.cwd(), '..', 'packages/content/data'),
exists: {
relPath: fs.existsSync(path.resolve(process.cwd(), '../../packages/content/data')),
absPath: fs.existsSync(path.resolve(process.cwd(), '..', 'packages/content/data'))
},
contentDirs: {}
}
// Check if content directories exist
try {
const contentDir = paths.exists.relPath ? paths.relPath : paths.absPath
const dirs = ['websites', 'guides', 'resources', 'legal']
type ContentDirInfo = {
path: string
exists: boolean
files: number
}
paths.contentDirs = dirs.reduce<Record<string, ContentDirInfo>>((acc, dir) => {
const dirPath = path.join(contentDir, dir)
acc[dir] = {
path: dirPath,
exists: fs.existsSync(dirPath),
files: fs.existsSync(dirPath) ? fs.readdirSync(dirPath).length : 0
}
return acc
}, {})
} catch (error: unknown) {
const errorMessage = error instanceof Error ? error.message : String(error)
const errorStack = error instanceof Error ? error.stack : undefined
return NextResponse.json({
paths,
error: errorMessage,
stack: errorStack
})
}
return NextResponse.json(paths)
}