@kaifronsdal/transcript-viewer
Version:
A web-based viewer for AI conversation transcripts with rollback support
27 lines (21 loc) • 976 B
text/typescript
import { json, error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { loadCachedTranscriptsMetadataOnly } from '$lib/server/data-loading/cached-bulk-loader';
import { TRANSCRIPT_DIR } from '$lib/server/config';
import path from 'path';
// Returns an array of all transcript metadata objects.
// Optional query: rootDir (subdirectory under TRANSCRIPT_DIR)
export const GET: RequestHandler = async ({ url }) => {
try {
const subdirectoryPath = url.searchParams.get('rootDir');
const rootDir = subdirectoryPath
? path.resolve(TRANSCRIPT_DIR, subdirectoryPath)
: TRANSCRIPT_DIR;
const result = await loadCachedTranscriptsMetadataOnly(rootDir);
// Return transcripts as-is; client will handle path prefixing in links
return json(result.transcripts);
} catch (err: any) {
console.error('Metadata list API error:', err);
throw error(500, { message: 'Failed to load transcript metadata list' });
}
};