- Lenient parser for trueref.json and context7.json (trueref.json takes precedence) - Validates folders, excludeFolders, excludeFiles, rules, previousVersions - Stores config in repository_configs table - JSON Schema served at GET /api/v1/schema/trueref-config.json for IDE validation - Rules injected at top of every query-docs response Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
/**
|
|
* GET /api/v1/schema/trueref-config.json
|
|
*
|
|
* Returns the JSON Schema for the trueref.json repository configuration file.
|
|
* IDE tooling (VS Code, JetBrains, etc.) can reference this URL in the
|
|
* `$schema` field of a trueref.json file to get autocomplete and validation.
|
|
*
|
|
* Example trueref.json with schema reference:
|
|
* {
|
|
* "$schema": "http://localhost:5173/api/v1/schema/trueref-config.json",
|
|
* "projectTitle": "My Library",
|
|
* "rules": ["Always use named imports"]
|
|
* }
|
|
*/
|
|
|
|
import type { RequestHandler } from './$types';
|
|
import schema from '$lib/server/config/trueref-config.json' assert { type: 'json' };
|
|
import { CORS_HEADERS } from '$lib/server/api/formatters';
|
|
|
|
export const GET: RequestHandler = () => {
|
|
return new Response(JSON.stringify(schema, null, 2), {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/schema+json',
|
|
'Cache-Control': 'public, max-age=3600',
|
|
...CORS_HEADERS
|
|
}
|
|
});
|
|
};
|
|
|
|
export const OPTIONS: RequestHandler = () => {
|
|
return new Response(null, {
|
|
status: 204,
|
|
headers: CORS_HEADERS
|
|
});
|
|
};
|