This commit is contained in:
Mariano Gabriel
2026-07-05 22:59:27 -03:00
parent 8cfb4c2cbe
commit bb84558526
8 changed files with 245 additions and 29 deletions

View File

@@ -45,7 +45,8 @@ const VIDEO_MIME: Record<string, string> = {
}
export function meetusApi(opts: Options): Plugin {
const outputDir = path.resolve(opts.outputDir)
// Mutable so the UI can re-point the scan at another folder at runtime.
let outputDir = path.resolve(opts.outputDir)
const videoDir = opts.videoDir ? path.resolve(opts.videoDir) : null
/** Locate a run's source video. The manifest records an absolute path from
@@ -139,6 +140,22 @@ export function meetusApi(opts: Options): Plugin {
parts: string[],
logger: { warn: (m: string) => void },
): Promise<boolean> {
// GET/PUT the folder scanned (recursively) for meeting runs.
if (parts[0] === 'output') {
if (req.method === 'GET') { sendJson(res, 200, { dir: outputDir }); return true }
if (req.method === 'PUT') {
let body: { dir?: string }
try { body = JSON.parse((await readBody(req)) || '{}') } catch { sendJson(res, 400, { error: 'invalid JSON' }); return true }
const dir = (body.dir ?? '').trim()
try {
if (!dir || !fs.statSync(dir).isDirectory()) throw new Error('not a directory')
} catch { sendJson(res, 400, { error: `not a directory: ${dir}` }); return true }
outputDir = path.resolve(dir)
sendJson(res, 200, { dir: outputDir })
return true
}
}
if (parts[0] !== 'runs') return false
// GET /api/runs