Skip to content

Commit 162942a

Browse files
unibeckatinux
andauthored
feat: option to specify storage directory in development (nuxt-hub#112)
Co-authored-by: Sébastien Chopin <[email protected]>
1 parent 82acf09 commit 162942a

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

docs/content/docs/1.getting-started/2.installation.md

+25-5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ export default defineNuxtConfig({
7575
```
7676

7777
::field-group
78-
::field{name="remote" type="boolean|string"}
79-
Default to `false` - Allows working with remote storage (database, kv, blob) from your deployed project. :br
80-
[Read more about remote storage for usage](/docs/getting-started/remote-storage).
81-
::
82-
8378
::field{name="analytics" type="boolean"}
8479
Default to `false` - Enables analytics for your project (coming soon).
8580
::
@@ -99,8 +94,33 @@ export default defineNuxtConfig({
9994
::field{name="kv" type="boolean"}
10095
Default to `false` - Enables Key-Value to store JSON data accessible globally.
10196
::
97+
98+
::field{name="remote" type="boolean|string"}
99+
Default to `false` - Allows working with remote storage (database, kv, blob) from your deployed project. :br
100+
[Read more about remote storage for usage](/docs/getting-started/remote-storage).
101+
::
102+
103+
::field{name="dir" type="string"}
104+
Default to `'.data/hub'` - The directory used for storage (D1, KV, R2, etc.) in development mode.
105+
::
106+
102107
::
103108

104109
::tip{icon="i-ph-rocket-launch-duotone"}
105110
You're all set! Now, let's dive into connecting to your Cloudflare account and [deploying it on the Edge](/docs/getting-started/deploy).
106111
::
112+
113+
## Nightly Builds
114+
115+
You can also use the latest features and bug fixes (commited on the `main` branch) by installing the [nightly tag](https://www.npmjs.com/package/@nuxthub/core?activeTab=versions):
116+
117+
```diff [package.json]
118+
{
119+
"Dependencies": {
120+
- "@nuxthub/core": "^0.5.0"
121+
+ "@nuxthub/core": "npm:@nuxthub/core@nightly"
122+
}
123+
}
124+
```
125+
126+
Then run `npm install`, `pnpm install`, `yarn install` or `bun install` to update the dependency.

src/module.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ export interface ModuleOptions {
8080
* @default process.env.NUXT_HUB_PROJECT_SECRET_KEY
8181
*/
8282
projectSecretKey?: string
83+
/**
84+
* The directory used for storage (D1, KV, R2, etc.) in development mode.
85+
* @default '.data/hub'
86+
*/
87+
dir?: string
8388
}
8489

8590
export default defineNuxtModule<ModuleOptions>({
@@ -107,6 +112,8 @@ export default defineNuxtModule<ModuleOptions>({
107112
// Remote storage
108113
remote: remoteArg || process.env.NUXT_HUB_REMOTE,
109114
remoteManifest: undefined,
115+
// Local storage
116+
dir: '.data/hub',
110117
// NuxtHub features
111118
analytics: false,
112119
blob: false,
@@ -378,10 +385,10 @@ export default defineNuxtModule<ModuleOptions>({
378385

379386
// Local development without remote connection
380387
if (nuxt.options.dev && !hub.remote) {
381-
log.info('Using local storage from `.data/hub`')
388+
log.info(`Using local storage from \`${hub.dir}\``)
382389

383-
// Create the .data/hub/ directory
384-
const hubDir = join(rootDir, './.data/hub')
390+
// Create the hub.dir directory
391+
const hubDir = join(rootDir, hub.dir)
385392
try {
386393
await mkdir(hubDir, { recursive: true })
387394
} catch (e: any) {

0 commit comments

Comments
 (0)