singularity-forge/web/pages/api/projects.ts
Mikael Hugo 365c6bbc3b
Some checks are pending
CI / detect-changes (push) Waiting to run
CI / docs-check (push) Blocked by required conditions
CI / lint (push) Blocked by required conditions
CI / build (push) Blocked by required conditions
CI / integration-tests (push) Blocked by required conditions
CI / windows-portability (push) Blocked by required conditions
CI / rtk-portability (linux, blacksmith-4vcpu-ubuntu-2404) (push) Blocked by required conditions
CI / rtk-portability (macos, macos-15) (push) Blocked by required conditions
CI / rtk-portability (windows, blacksmith-4vcpu-windows-2025) (push) Blocked by required conditions
chore: formatter / linter touch-up (230 files)
Pure formatting / lint-fix pass that ran during `npm run build:core`
in the session that landed the agent-runner / quota / coverage /
phase-2 routing work. No logic changes — indentation, trailing
commas, import sort, etc. Captured separately so the actual feature
commits stay scoped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 21:19:53 +02:00

26 lines
881 B
TypeScript

import { readdirSync, statSync } from "node:fs";
import { join } from "node:path";
import type { NextApiRequest, NextApiResponse } from "next";
// Returns a list of subfolders in the dev root that contain a .sf directory
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const devRoot = req.query.devRoot as string;
if (!devRoot) return res.status(400).json({ error: "Missing devRoot" });
let projects: string[] = [];
try {
const entries = readdirSync(devRoot, { withFileTypes: true });
projects = entries
.filter((entry) => entry.isDirectory())
.filter((entry) => {
try {
return statSync(join(devRoot, entry.name, ".sf")).isDirectory();
} catch {
return false;
}
})
.map((entry) => entry.name);
res.status(200).json({ projects });
} catch (e) {
res.status(500).json({ error: (e as Error).message });
}
}