Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shafiqihtsham committed Sep 21, 2024
1 parent 8e6e301 commit e6b312d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions server/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ function mapRequestToDocs(req: Request): Request {
return new Request(assetUrl.toString(), assetRequest);
}

router.all("*", async (req: Request, env: Env, ctx: ExecutionContext) => {
router.all('*', async (req: Request, env: Env, ctx: ExecutionContext) => {
const cacheControl = {
edgeTTL: 2 * 24 * 60 * 60,
bypassCache: env.POLYKEY_DOCS_ENV === "development" ? true : false,
bypassCache: env.POLYKEY_DOCS_ENV === 'development' ? true : false,
};
const url = new URL(req.url);
// Check if the URL pathname is exactly '/docs'
Expand All @@ -57,16 +57,16 @@ router.all("*", async (req: Request, env: Env, ctx: ExecutionContext) => {
},
);

if (req.url.includes("assets")) {
response.headers.set("Cache-Control", "max-age=31536000, immutable");
if (req.url.includes('assets')) {
response.headers.set('Cache-Control', 'max-age=31536000, immutable');
} else {
response.headers.set("Cache-Control", "max-age=86400");
response.headers.set('Cache-Control', 'max-age=86400');
}

return response;
} catch (e) {
if (e instanceof cloudflareKVAssetHandler.NotFoundError) {
console.log("Requested resource not found", e.message);
console.log('Requested resource not found', e.message);
const response404 = await cloudflareKVAssetHandler.getAssetFromKV(
{
request: req,
Expand All @@ -85,17 +85,17 @@ router.all("*", async (req: Request, env: Env, ctx: ExecutionContext) => {

const headers = new Headers(response404.headers);

headers.set("Cache-Control", "max-age=86400");
headers.set('Cache-Control', 'max-age=86400');

return new Response(response404.body, {
...response404,
headers,
status: 404,
});
} else if (e instanceof cloudflareKVAssetHandler.MethodNotAllowedError) {
return new Response("Method Not Allowed", { status: 405 });
return new Response('Method Not Allowed', { status: 405 });
} else {
return new Response("Server Error", { status: 500 });
return new Response('Server Error', { status: 500 });
}
}
});
Expand Down

0 comments on commit e6b312d

Please sign in to comment.