Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
chore: use tabs for indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherry committed Dec 9, 2022
1 parent 0940926 commit 4ded85a
Show file tree
Hide file tree
Showing 11 changed files with 954 additions and 946 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
@@ -0,0 +1,7 @@
# https://editorconfig.org
root = true

[*]
end_of_line = lf
indent_style = tab
tab_width = 2
13 changes: 7 additions & 6 deletions .prettierrc
@@ -1,7 +1,8 @@
{
"endOfLine": "lf",
"trailingComma": "all",
"singleQuote": true,
"semi": false,
"printWidth": 100
}
"endOfLine": "lf",
"trailingComma": "all",
"singleQuote": true,
"useTabs": true,
"semi": false,
"printWidth": 100
}
126 changes: 63 additions & 63 deletions README.md
Expand Up @@ -76,32 +76,32 @@ import manifestJSON from '__STATIC_CONTENT_MANIFEST'
const assetManifest = JSON.parse(manifestJSON)

export default {
async fetch(request, env, ctx) {
if (request.url.includes('/docs')) {
try {
return await getAssetFromKV(
{
request,
waitUntil(promise) {
return ctx.waitUntil(promise)
},
},
{
ASSET_NAMESPACE: env.__STATIC_CONTENT,
ASSET_MANIFEST: assetManifest,
},
)
} catch (e) {
if (e instanceof NotFoundError) {
// ...
} else if (e instanceof MethodNotAllowedError) {
// ...
} else {
return new Response('An unexpected error occurred', { status: 500 })
}
}
} else return fetch(request)
},
async fetch(request, env, ctx) {
if (request.url.includes('/docs')) {
try {
return await getAssetFromKV(
{
request,
waitUntil(promise) {
return ctx.waitUntil(promise)
},
},
{
ASSET_NAMESPACE: env.__STATIC_CONTENT,
ASSET_MANIFEST: assetManifest,
},
)
} catch (e) {
if (e instanceof NotFoundError) {
// ...
} else if (e instanceof MethodNotAllowedError) {
// ...
} else {
return new Response('An unexpected error occurred', { status: 500 })
}
}
} else return fetch(request)
},
}
```

Expand All @@ -111,23 +111,23 @@ export default {
import { getAssetFromKV, NotFoundError, MethodNotAllowedError } from '@cloudflare/kv-asset-handler'

addEventListener('fetch', (event) => {
event.respondWith(handleEvent(event))
event.respondWith(handleEvent(event))
})

async function handleEvent(event) {
if (event.request.url.includes('/docs')) {
try {
return await getAssetFromKV(event)
} catch (e) {
if (e instanceof NotFoundError) {
// ...
} else if (e instanceof MethodNotAllowedError) {
// ...
} else {
return new Response('An unexpected error occurred', { status: 500 })
}
}
} else return fetch(event.request)
if (event.request.url.includes('/docs')) {
try {
return await getAssetFromKV(event)
} catch (e) {
if (e instanceof NotFoundError) {
// ...
} else if (e instanceof MethodNotAllowedError) {
// ...
} else {
return new Response('An unexpected error occurred', { status: 500 })
}
}
} else return fetch(event.request)
}
```

Expand Down Expand Up @@ -173,9 +173,9 @@ type: object

```javascript
let cacheControl = {
browserTTL: null, // do not set cache control ttl on responses
edgeTTL: 2 * 60 * 60 * 24, // 2 days
bypassCache: false, // do not bypass Cloudflare's cache
browserTTL: null, // do not set cache control ttl on responses
edgeTTL: 2 * 60 * 60 * 24, // 2 days
bypassCache: false, // do not bypass Cloudflare's cache
}
```

Expand Down Expand Up @@ -213,15 +213,15 @@ In ES Modules format, this argument is required, and can be gotten from `env`.

```js
return getAssetFromKV(
{
request,
waitUntil(promise) {
return ctx.waitUntil(promise)
},
},
{
ASSET_NAMESPACE: env.__STATIC_CONTENT,
},
{
request,
waitUntil(promise) {
return ctx.waitUntil(promise)
},
},
{
ASSET_NAMESPACE: env.__STATIC_CONTENT,
},
)
```

Expand Down Expand Up @@ -249,16 +249,16 @@ let manifest = JSON.parse(manifestJSON)
manifest['index.html'] = 'index.special.html'

return getAssetFromKV(
{
request,
waitUntil(promise) {
return ctx.waitUntil(promise)
},
},
{
ASSET_MANIFEST: manifest,
// ...
},
{
request,
waitUntil(promise) {
return ctx.waitUntil(promise)
},
},
{
ASSET_MANIFEST: manifest,
// ...
},
)
```

Expand Down Expand Up @@ -328,7 +328,7 @@ To turn `etags` **off**, you must bypass cache:
```js
/* Turn etags off */
let cacheControl = {
bypassCache: true,
bypassCache: true,
}
```

Expand Down

0 comments on commit 4ded85a

Please sign in to comment.