import { app } from '@/app.ts'; import path from 'node:path' import glob from 'fast-glob'; import fs from 'node:fs' const list = async () => { const root = path.join(process.cwd(), 'code'); const files = await glob('**/*.ts', { cwd: root }); type FileContent = { path: string; content: string; } const filesContent: FileContent[] = []; for (const file of files) { if (file.startsWith('node_modules') || file.startsWith('dist') || file.startsWith('.git')) continue; const fullPath = path.join(root, file); const content = fs.readFileSync(fullPath, 'utf-8'); if (content) { filesContent.push({ path: file, content: content }); } } return filesContent; } app.route({ path: 'file-code' }).define(async (ctx) => { const files = await list(); ctx.body = files }).addTo(app);