docs: document custom storage drivers - #4464
Conversation
Explain that driver must be a built-in name or module path, with an example. Closes nitrojs#3847.
|
@vittorioexp is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds documentation for configuring Nitro storage with built-in driver names or custom driver module paths, including a ChangesStorage driver configuration
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/1.docs/8.storage.md`:
- Around line 110-112: Update the Upstash example imports to use the default
export from unstorage/drivers/upstash instead of a named import, and document
`@upstash/redis` as a prerequisite dependency for users copying the example.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c92d638b-0ab7-49ad-9a3c-8f2c67fd8f0e
📒 Files selected for processing (1)
docs/1.docs/8.storage.md
| ```ts [drivers/upstash.ts] | ||
| import { defineDriver } from "unstorage"; | ||
| import { upstashDriver } from "unstorage/drivers/upstash"; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== docs/1.docs/8.storage.md (relevant section) =="
nl -ba docs/1.docs/8.storage.md | sed -n '90,130p'
echo
echo "== search for upstash mentions =="
rg -n "upstash|`@upstash/redis`|defineDriver|unstorage/drivers/upstash" docs/1.docs/8.storage.md docs -SRepository: nitrojs/nitro
Length of output: 241
🌐 Web query:
unstorage upstash driver default import @upstash/redis documentation
💡 Result:
The Unstorage Upstash driver is imported using the default export from the package location 'unstorage/drivers/upstash' [1][2]. To use the Upstash driver in your Unstorage project, you must have the '@upstash/redis' package installed [1]. The driver is initialized as follows: import { createStorage } from "unstorage"; import upstashDriver from "unstorage/drivers/upstash"; const storage = createStorage({ driver: upstashDriver({ base: "unstorage", // url: "...", // Optional: or set UPSTASH_REDIS_REST_URL env var // token: "...", // Optional: or set UPSTASH_REDIS_REST_TOKEN env var }), }); The driver automatically looks for the UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN environment variables if they are not explicitly provided in the options [1]. For comprehensive details on configuring the underlying Upstash client, you should refer to the official @upstash/redis documentation [1][3].
Citations:
- 1: https://unstorage.unjs.io/drivers/upstash
- 2: https://context7.com/unjs/unstorage/llms.txt?tokens=10000
- 3: https://upstash.com/docs/redis/howto/connectwithupstashredis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== relevant lines from docs/1.docs/8.storage.md =="
sed -n '90,130p' docs/1.docs/8.storage.md
echo
echo "== upstash-related matches in docs/1.docs/8.storage.md =="
grep -nE 'upstash|`@upstash/redis`|defineDriver|unstorage/drivers/upstash' docs/1.docs/8.storage.md || trueRepository: nitrojs/nitro
Length of output: 1876
Use the default Upstash import and add the dependency note.
unstorage/drivers/upstash is a default export, so this named import will break the example. Add @upstash/redis as a prerequisite for copy-paste users.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/1.docs/8.storage.md` around lines 110 - 112, Update the Upstash example
imports to use the default export from unstorage/drivers/upstash instead of a
named import, and document `@upstash/redis` as a prerequisite dependency for users
copying the example.
|
|
||
| ```ts [drivers/upstash.ts] | ||
| import { defineDriver } from "unstorage"; | ||
| import { upstashDriver } from "unstorage/drivers/upstash"; |
There was a problem hiding this comment.
This is bad for the example of custom drivers / relavant to wrap to patch but making from scratch, ony needs implemeneting the interface
Address review feedback: from-scratch drivers implement the unstorage interface; wrapping is only for patching existing drivers. Co-authored-by: Cursor <cursoragent@cursor.com>
commit: |
Summary
Closes #3847.
Documents how to register custom unstorage drivers via a file path in nitro.config, with an example based on maintainer guidance.
Test plan
Made with Cursor