Skip to content

Instantly share code, notes, and snippets.

@lmaccherone
Last active March 2, 2023 00:58
Show Gist options
  • Save lmaccherone/67df5ae9977dfd808e8ffd6a6cb62bd6 to your computer and use it in GitHub Desktop.
Save lmaccherone/67df5ae9977dfd808e8ffd6a6cb62bd6 to your computer and use it in GitHub Desktop.
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