const fs = require('fs'); const content = fs.readFileSync('final-backend.js', 'utf8'); const lines = content.split('\n'); // 提取所有路由 const routes = []; for (let i = 0; i < lines.length; i++) { const line = lines[i]; const match = line.match(/app\.(get|post|put|delete|patch)\(['\"](\/api\/[^'\"]+)['\"]/); if (match) { routes.push({ method: match[1], path: match[2], line: i + 1 }); } } console.log(`共找到 ${routes.length} 个路由`); // 按模块分组 const modules = {}; routes.forEach(route => { const path = route.path; let moduleName = 'other'; if (path.startsWith('/api/auth')) moduleName = 'auth'; else if (path.startsWith('/api/users')) moduleName = 'users'; else if (path.startsWith('/api/customers')) moduleName = 'customers'; else if (path.startsWith('/api/suppliers')) moduleName = 'suppliers'; else if (path.startsWith('/api/subcontractors')) moduleName = 'subcontractors'; else if (path.startsWith('/api/projects')) moduleName = 'projects'; else if (path.startsWith('/api/products')) moduleName = 'products'; else if (path.startsWith('/api/categories')) moduleName = 'categories'; else if (path.startsWith('/api/budget-projects')) moduleName = 'budget-projects'; else if (path.startsWith('/api/exchange-rates')) moduleName = 'exchange-rates'; else if (path.startsWith('/api/advances')) moduleName = 'advances'; else if (path.startsWith('/api/payment-requests')) moduleName = 'payment-requests'; else if (path.startsWith('/api/verifications')) moduleName = 'verifications'; else if (path.startsWith('/api/executions')) moduleName = 'executions'; else if (path.startsWith('/api/reimbursements')) moduleName = 'reimbursements'; else if (path.startsWith('/api/purchase-requests')) moduleName = 'purchase-requests'; else if (path.startsWith('/api/purchase-orders')) moduleName = 'purchase-orders'; else if (path.startsWith('/api/payment-plans')) moduleName = 'payment-plans'; else if (path.startsWith('/api/inventory')) moduleName = 'inventory'; else if (path.startsWith('/api/upload')) moduleName = 'upload'; else if (path === '/api/health' || path === '/status' || path === '/welcome' || path === '/' || path === '/api-docs') moduleName = 'system'; if (!modules[moduleName]) modules[moduleName] = []; modules[moduleName].push(route); }); console.log('\n模块名 | 路径前缀 | 路由数量 | 起始行-结束行'); console.log('------|----------|----------|--------------'); for (const [moduleName, moduleRoutes] of Object.entries(modules)) { const lineNumbers = moduleRoutes.map(r => r.line); const startLine = Math.min(...lineNumbers); const endLine = Math.max(...lineNumbers); // 简单估算结束行 let estimatedEndLine = endLine; for (let i = endLine; i < Math.min(endLine + 100, lines.length); i++) { if (lines[i].includes('// ====================') || lines[i].includes('app.') && lines[i].includes('/api/')) { const nextPath = lines[i].match(/['\"](\/api\/[^'\"]+)['\"]/); if (nextPath && !nextPath[1].startsWith(`/api/${moduleName}`)) { estimatedEndLine = i - 1; break; } } } const pathPrefix = moduleName === 'system' ? '/api' : `/api/${moduleName}`; console.log(`${moduleName} | ${pathPrefix} | ${moduleRoutes.length} | ${startLine}-${estimatedEndLine}`); }