Skip to content

Commit db92467

Browse files
committed
fix: set fs-lite as default only if nothing defined
1 parent f7ff482 commit db92467

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/features/blob.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ const log = logger.withTag('nuxt:hub')
1515
export function setupBlob(nuxt: Nuxt, hub: HubConfig) {
1616
// Configure dev storage
1717
nuxt.options.nitro.devStorage ||= {}
18-
nuxt.options.nitro.devStorage.blob = defu(nuxt.options.nitro.devStorage.blob, {
19-
driver: 'fs-lite',
20-
base: join(hub.dir!, 'blob')
21-
})
18+
19+
if (!nuxt.options.nitro.devStorage.blob) {
20+
nuxt.options.nitro.devStorage.blob = {
21+
driver: 'fs-lite',
22+
base: join(hub.dir!, 'blob')
23+
}
24+
}
2225

2326
// Add Server scanning
2427
addServerScanDir(resolve('runtime/blob/server'))
@@ -43,13 +46,13 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
4346
log.info(`\`hubBlob()\` configured with \`${nitro.options.storage.blob.driver}\` driver (defined in \`nuxt.config.ts\`)`)
4447
return
4548
}
46-
let kvConfig: NitroOptions['storage']['blob']
49+
let blobConfig: NitroOptions['storage']['blob']
4750

4851
switch (preset) {
4952
// Does your favourite cloud provider require special configuration? Feel free to open a PR to add zero-config support for other presets
5053

5154
case 'vercel': {
52-
kvConfig = {
55+
blobConfig = {
5356
driver: 'vercel-blob',
5457
access: 'public'
5558
}
@@ -60,7 +63,7 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
6063
case 'cloudflare-module':
6164
case 'cloudflare-durable':
6265
case 'cloudflare-pages': {
63-
kvConfig = {
66+
blobConfig = {
6467
driver: 'cloudflare-r2-binding',
6568
bindingName: 'BLOB'
6669
}
@@ -69,7 +72,7 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
6972
}
7073

7174
case 'netlify': {
72-
kvConfig = {
75+
blobConfig = {
7376
driver: 'netlify-blobs',
7477
name: process.env.NETLIFY_BLOB_STORE_NAME
7578
}
@@ -80,7 +83,7 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
8083
}
8184
case 'azure':
8285
case 'azure-functions': {
83-
kvConfig = {
86+
blobConfig = {
8487
driver: 'azure-storage-blob',
8588
accountName: process.env.AZURE_BLOB_ACCOUNT_NAME
8689
}
@@ -92,7 +95,7 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
9295

9396
case 'aws-lambda':
9497
case 'aws-amplify': {
95-
kvConfig = {
98+
blobConfig = {
9699
driver: 's3',
97100
accessKeyId: process.env.S3_ACCESS_KEY_ID,
98101
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
@@ -107,7 +110,7 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
107110
}
108111

109112
case 'digital-ocean': {
110-
kvConfig = {
113+
blobConfig = {
111114
driver: 's3',
112115
accessKeyId: process.env.SPACES_KEY,
113116
secretAccessKey: process.env.SPACES_SECRET,
@@ -122,17 +125,17 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
122125
}
123126

124127
default: {
125-
kvConfig = {
128+
blobConfig = {
126129
driver: 'fs-lite',
127130
base: '.data/blob'
128131
}
129132
break
130133
}
131134
}
132135

133-
if (kvConfig) {
136+
if (blobConfig) {
134137
// check if driver dependencies are installed
135-
switch (kvConfig.driver) {
138+
switch (blobConfig.driver) {
136139
case 'vercel-blob':
137140
await ensureDependencyInstalled('@vercel/blob')
138141
break
@@ -150,7 +153,7 @@ export async function setupProductionBlob(nitro: Nitro, _hub: HubConfig) {
150153

151154
// set driver
152155
nitro.options.storage ||= {}
153-
nitro.options.storage.blob = defu(nitro.options.storage?.blob, kvConfig)
154-
log.info(`\`hubBlob()\` configured with \`${kvConfig.driver}\` driver`)
156+
nitro.options.storage.blob = defu(nitro.options.storage?.blob, blobConfig)
157+
log.info(`\`hubBlob()\` configured with \`${blobConfig.driver}\` driver`)
155158
}
156159
}

0 commit comments

Comments
 (0)