Components are now .vue files in user-components/<folder>/ parsed at runtime. Replaces 6 DB MCP tools with 2 (list_fs_components, load_fs_component). Adds vue-parser, fs-components API, and file watcher for live reload.
25 lines
799 B
TypeScript
25 lines
799 B
TypeScript
import { join } from 'path'
|
|
import { jsonResponse, errorResponse } from '../utils/cors'
|
|
import { USER_COMPONENTS_DIR, WORKING_DIR } from '../config'
|
|
import { listAllComponents, parseComponentFolder } from '../services/vue-parser'
|
|
|
|
const baseDir = join(WORKING_DIR, USER_COMPONENTS_DIR)
|
|
|
|
export function handleFsComponents(req: Request) {
|
|
if (req.method !== 'GET') return null
|
|
|
|
const components = listAllComponents(baseDir)
|
|
return jsonResponse(components)
|
|
}
|
|
|
|
export function handleFsComponentByName(req: Request, folderName: string) {
|
|
if (req.method !== 'GET') return null
|
|
|
|
const component = parseComponentFolder(baseDir, folderName)
|
|
if (!component) {
|
|
return errorResponse(`Component folder "${folderName}" not found or has no .vue file`, 404)
|
|
}
|
|
|
|
return jsonResponse(component)
|
|
}
|