Skip to content

Commit c882c22

Browse files
committed
feat: added /schema.json route
1 parent 0864600 commit c882c22

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

web/src/routes/schema.json/+server.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { error } from '@sveltejs/kit';
2+
3+
export async function GET() {
4+
const schemaURL = "https://raw.githubusercontent.com/gttp-cli/gttp/main/schema.json";
5+
6+
try {
7+
const response = await fetch(schemaURL);
8+
if (!response.ok) {
9+
throw new Error('Failed to fetch schema');
10+
}
11+
const data = await response.json();
12+
13+
return new Response(JSON.stringify(data), {
14+
headers: {
15+
'Content-Type': 'application/json'
16+
}
17+
});
18+
} catch (e) {
19+
// Handle errors or invalid responses
20+
throw error(500, `Error fetching schema: ${e.message}`);
21+
}
22+
}

web/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# $schema:
1+
# $schema: https://gttp.dev/schema

0 commit comments

Comments
 (0)