Skip to content

Commit dfc7cd5

Browse files
committed
fix formatting
1 parent 80ee957 commit dfc7cd5

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

src/middleware.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,47 @@ export const remix = ({ mode, build, getLoadContext }: RemixMiddlewareOptions) =
2323
})
2424
}
2525

26-
2726
/**
28-
* A string of directives for the Cache-Control header.
29-
* See the [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) docs for more information.
30-
*/
27+
* A string of directives for the Cache-Control header.
28+
* See the [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) docs for more information.
29+
*/
3130

32-
type CacheControl= string;
31+
type CacheControl = string
3332

3433
interface StaticAssetsOptions {
35-
cache?: CacheControl;
34+
cache?: CacheControl
3635
}
3736

3837
export function staticAssets(options: StaticAssetsOptions = {}) {
39-
return createMiddleware(async (c, next) => {
40-
let binding = c.env?.ASSETS as Fetcher | undefined;
38+
return createMiddleware(async (c, next) => {
39+
const binding = c.env?.ASSETS as Fetcher | undefined
4140

42-
if (!binding) throw new ReferenceError("The binding ASSETS is not set.");
41+
if (!binding) {
42+
throw new ReferenceError('The binding ASSETS is not set.')
43+
}
4344

44-
let response: Response;
45+
let response: Response
4546

46-
c.req.raw.headers.delete("if-none-match");
47+
c.req.raw.headers.delete('if-none-match')
4748

48-
try {
49-
response = await binding.fetch(c.req.url, c.req.raw.clone());
49+
try {
50+
response = await binding.fetch(c.req.url, c.req.raw.clone())
5051

51-
// If the request failed, we just call the next middleware
52-
if (response.status >= 400) return await next();
52+
// If the request failed, we just call the next middleware
53+
if (response.status >= 400) {
54+
return await next()
55+
}
5356

54-
response = new Response(response.body, response);
57+
response = new Response(response.body, response)
5558

56-
// If cache options are configured, we set the cache-control header
57-
if (options.cache) {
58-
response.headers.set("cache-control", );
59-
}
59+
// If cache options are configured, we set the cache-control header
60+
if (options.cache) {
61+
response.headers.set('cache-control', options.cache)
62+
}
6063

61-
return response;
62-
} catch {
63-
return await next();
64-
}
65-
});
64+
return response
65+
} catch {
66+
return await next()
67+
}
68+
})
6669
}

0 commit comments

Comments
 (0)