workers-site: fix type errors

This commit is contained in:
Harsh Shandilya 2022-01-02 17:52:53 +05:30
parent e40be3511a
commit 36c8fb2cfa
1 changed files with 5 additions and 2 deletions

View File

@ -30,7 +30,7 @@ async function getPageFromKV(event: FetchEvent): Promise<Response> {
response.headers.set('Cache-Control', 'public, max-age=31536000');
}
return response
} catch (e) {
} catch (e: unknown) {
try {
let notFoundResponse = await getAssetFromKV(event, {
mapRequestToAsset: (req) =>
@ -41,8 +41,11 @@ async function getPageFromKV(event: FetchEvent): Promise<Response> {
status: 404,
})
} catch (e) {}
return new Response(e.message || e.toString(), { status: 500 })
if (e instanceof Error) {
return new Response(e.message || e.toString(), { status: 500 });
}
}
return new Response("Failed to load page", { status: 500 });
}
async function redirectGitHub(event: FetchEvent): Promise<Response> {