Skip to content

Commit cc47fb1

Browse files
committed
make it an ISR route, handle errors
1 parent b6f36f3 commit cc47fb1

File tree

1 file changed

+15
-7
lines changed
  • apps/svelte.dev/src/routes/devtools/updates.json

1 file changed

+15
-7
lines changed

apps/svelte.dev/src/routes/devtools/updates.json/+server.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1+
import { error, json } from '@sveltejs/kit';
2+
import type { ServerlessConfig } from '@sveltejs/adapter-vercel';
3+
4+
export const config: ServerlessConfig = {
5+
isr: {
6+
expiration: 300
7+
}
8+
};
9+
110
// We manage FF extension by ourselves through GH releases and this acts as `update_url`
211
// for our users to automatically update their extension when a new version is released
312
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#update_url
13+
export async function GET({ fetch }) {
14+
const response = await fetch('https://api.github.com/repos/sveltejs/svelte-devtools/tags');
415

5-
import { json } from '@sveltejs/kit';
6-
7-
export const prerender = true;
16+
if (!response.ok) {
17+
error(response.status);
18+
}
819

9-
export async function GET({ fetch }) {
10-
const gh: Array<{ name: string }> = await fetch(
11-
'https://api.github.com/repos/sveltejs/svelte-devtools/tags'
12-
).then((r) => r.json());
20+
const gh: Array<{ name: string }> = await response.json();
1321

1422
// v2.2.0 is the first version that has the Firefox extension
1523
const tags = gh.reverse().slice(gh.findIndex((t) => t.name === 'v2.2.0'));

0 commit comments

Comments
 (0)