Created
March 17, 2020 04:53
-
-
Save shagamemnon/36e7529e2b593bc7257e42a342335d86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event)) | |
}) | |
async function timeout (ms) { | |
return new Promise(accept => { | |
setTimeout(() => { | |
accept('timeout') | |
}, ms) | |
}) | |
} | |
async function handleRequest (request) { | |
if (request.cf.botManagement.score && request.cf.botManagement.score < 70) { | |
await timeout(5000) | |
} | |
return fetch(request) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment