Run prettier
This commit is contained in:
parent
4f93d37e39
commit
be818dc661
1 changed files with 4 additions and 8 deletions
12
index.js
12
index.js
|
|
@ -1,6 +1,6 @@
|
|||
let secret
|
||||
|
||||
addEventListener('fetch', event => {
|
||||
addEventListener('fetch', (event) => {
|
||||
event.respondWith(handleRequest(event.request))
|
||||
})
|
||||
|
||||
|
|
@ -10,8 +10,8 @@ addEventListener('fetch', event => {
|
|||
*/
|
||||
async function handleRequest(request) {
|
||||
// Set this in your worker's environment. wrangler.toml or cloudflare dashboard
|
||||
if (WORKERLINKS_SECRET === undefined ) {
|
||||
return new Response("Secret is not defined. Please add WORKERLINKS_SECRET.")
|
||||
if (WORKERLINKS_SECRET === undefined) {
|
||||
return new Response('Secret is not defined. Please add WORKERLINKS_SECRET.')
|
||||
} else {
|
||||
secret = WORKERLINKS_SECRET
|
||||
}
|
||||
|
|
@ -40,11 +40,7 @@ async function handleRequest(request) {
|
|||
},
|
||||
)
|
||||
}
|
||||
key =
|
||||
'/' +
|
||||
Math.random()
|
||||
.toString(36)
|
||||
.slice(5)
|
||||
key = '/' + Math.random().toString(36).slice(5)
|
||||
shorturl = new URL(request.url).origin + key
|
||||
return await putLink(
|
||||
request.headers.get('Authorization'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue