Skip to content

Commit

Permalink
feat: added /schema.json route
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Feb 5, 2024
1 parent 0864600 commit c882c22
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions web/src/routes/schema.json/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { error } from '@sveltejs/kit';

export async function GET() {
const schemaURL = "https://raw.githubusercontent.com/gttp-cli/gttp/main/schema.json";

try {
const response = await fetch(schemaURL);
if (!response.ok) {
throw new Error('Failed to fetch schema');
}
const data = await response.json();

return new Response(JSON.stringify(data), {
headers: {
'Content-Type': 'application/json'
}
});
} catch (e) {
// Handle errors or invalid responses
throw error(500, `Error fetching schema: ${e.message}`);
}
}
2 changes: 1 addition & 1 deletion web/test.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# $schema:
# $schema: https://gttp.dev/schema

0 comments on commit c882c22

Please sign in to comment.