Last active
March 2, 2023 00:58
-
-
Save lmaccherone/67df5ae9977dfd808e8ffd6a6cb62bd6 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
async function addCryptoToEnv(env) { | |
if (globalThis.crypto == null) { | |
try { | |
env.crypto = await import('crypto') | |
} catch (err) { | |
throw new Error('crypto support not available!') | |
} | |
} else { | |
env.crypto = globalThis.crypto | |
} | |
return env | |
} | |
const env = getMiniflareBindings() | |
await addCryptoToEnv(env) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment