23 lines
754 B
JavaScript
23 lines
754 B
JavaScript
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
|
|
const appDir = path.join(__dirname, "..", "app");
|
|
const groupsDir = path.join(appDir, "groups");
|
|
|
|
function hasDynamicRoute(dir) {
|
|
if (!fs.existsSync(dir)) return false;
|
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
for (const entry of entries) {
|
|
if (!entry.isDirectory()) continue;
|
|
if (entry.name.startsWith("[") && entry.name.endsWith("]")) return true;
|
|
const nested = path.join(dir, entry.name);
|
|
if (hasDynamicRoute(nested)) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
if (hasDynamicRoute(groupsDir)) {
|
|
console.error("Forbidden dynamic group route detected under app/groups. Remove any [id] routes.");
|
|
process.exit(1);
|
|
}
|