(routes: readonly Node[], navigates: number)
| 1644 | * app; both — pages and the endpoints behind them — make a web app. |
| 1645 | */ |
| 1646 | export function projectKind(routes: readonly Node[], navigates: number): 'app' | 'api' | 'web' { |
| 1647 | let endpoints = 0; |
| 1648 | let pages = 0; |
| 1649 | for (const r of routes) { |
| 1650 | if (splitRouteName(r.name).method !== null) endpoints++; |
| 1651 | else if (r.name.startsWith('/')) { |
| 1652 | pages++; |
| 1653 | // A Next page is a web page whatever else the index holds. |
| 1654 | if (nextRouteForFile(r.filePath)?.kind === 'page') return 'web'; |
| 1655 | } |
| 1656 | } |
| 1657 | if (endpoints === 0) return 'app'; |
| 1658 | return navigates > 0 || pages > 0 ? 'web' : 'api'; |
| 1659 | } |
| 1660 | |
| 1661 | function basename(p: string): string { |
| 1662 | const s = posix(p); |
no test coverage detected