We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9bced60 commit 06a90f4Copy full SHA for 06a90f4
src/pages/apiIndex.json.ts
@@ -0,0 +1,27 @@
1
+import type { APIRoute } from 'astro'
2
+import { getApiIndex } from '../utils/apiIndex/get'
3
+
4
+// Prerender at build time so this doesn't run in the Cloudflare Worker
5
+export const prerender = true
6
7
+export const GET: APIRoute = async () => {
8
+ try {
9
+ const index = await getApiIndex()
10
+ return new Response(JSON.stringify(index), {
11
+ status: 200,
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ },
15
+ })
16
+ } catch (error) {
17
+ return new Response(
18
+ JSON.stringify({ error: 'Failed to load API index' }),
19
+ {
20
+ status: 500,
21
22
23
24
+ }
25
+ )
26
27
+}
0 commit comments