Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default defineNuxtConfig({
blob: true,
cache: true,
bindings: {
compatibilityFlags: ['nodejs_compat_v2'],
// Used for /api/hyperdrive
hyperdrive: {
POSTGRES: '8bb2913857b84c939cd908740fa5a5d5'
Expand Down
12 changes: 12 additions & 0 deletions playground/server/api/crypto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default eventHandler(async () => {
// Available in nodejs_compat_v2
const crypto = globalThis['process']?.getBuiltinModule?.('crypto')
const hash = await new Promise((resolve, reject) => {
crypto.scrypt('hello-world', crypto.randomUUID(), 64, (err, hash) => {
if (err) return reject(err)
resolve(hash.toString('hex'))
})
})

return { hash: `scrypt:${hash}` }
})
2 changes: 2 additions & 0 deletions src/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface HubConfig {
kv?: boolean

bindings?: {
compatibilityDate?: string
compatibilityFlags?: string[]
hyperdrive?: {
[key: string]: string
}
Expand Down
11 changes: 11 additions & 0 deletions src/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ export interface ModuleOptions {
* @default {}
*/
bindings?: {
/**
* The compatibility date for the project.
* @see https://developers.cloudflare.com/workers/configuration/compatibility-dates/
*/
compatibilityDate?: string
/**
* Extra compatibility flags for the project.
* Note that NuxtHub will always add the 'nodejs_compat' flag if not specified.
* @see https://developers.cloudflare.com/workers/configuration/compatibility-dates/#compatibility-flags
*/
compatibilityFlags?: string[]
/**
* The hyperdrive bindings for the project, used only when deployed on Cloudflare.
* @see https://hub.nuxt.com/docs/features/hyperdrive
Expand Down