Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add upstash driver #500

Merged
merged 24 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
!startsWith(github.event.head_commit.message, 'docs')
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc &&
pnpm changelogen --canary nightly --publish --publishTag 2x
pnpm changelogen --canary nightly --publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,56 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## v1.13.1

[compare changes](https://github.com/unjs/unstorage/compare/v1.13.0...v1.13.1)

### 🩹 Fixes

- Revert chokidar to v3 ([#502](https://github.com/unjs/unstorage/pull/502))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))

## v1.13.0

[compare changes](https://github.com/unjs/unstorage/compare/v1.12.0...v1.13.0)

### 🚀 Enhancements

- Bump chokidar v4 ([#489](https://github.com/unjs/unstorage/pull/489))
- Add `null` driver ([#495](https://github.com/unjs/unstorage/pull/495))

### 🩹 Fixes

- **cloudflare-kv:** Use min ttl of 60 seconds ([#496](https://github.com/unjs/unstorage/pull/496))

### 💅 Refactors

- **netlify:** Support @netlify/blobs v8 and improve options types ([#486](https://github.com/unjs/unstorage/pull/486))
- **cli:** Migrate to `citty` ([#498](https://github.com/unjs/unstorage/pull/498))

### 📖 Documentation

- Missing values return null, not undefined ([#487](https://github.com/unjs/unstorage/pull/487))

### 🏡 Chore

- Update eslint config ([3dddf6c](https://github.com/unjs/unstorage/commit/3dddf6c))
- Update deps ([ee70d15](https://github.com/unjs/unstorage/commit/ee70d15))
- Update lockfile ([dca8dc9](https://github.com/unjs/unstorage/commit/dca8dc9))
- Revert msw back to 1.x ([cf7f3ce](https://github.com/unjs/unstorage/commit/cf7f3ce))

### ❤️ Contributors

- Alexander <a.hywax@gmail.com>
- Pooya Parsa ([@pi0](http://github.com/pi0))
- ToBinio ([@ToBinio](http://github.com/ToBinio))
- V1rtl ([@talentlessguy](http://github.com/talentlessguy))
- Philippe Serhal ([@serhalp](http://github.com/serhalp))
- Renato Lacerda <renato.ac.lacerda@gmail.com>

## v1.12.0

[compare changes](https://github.com/unjs/unstorage/compare/v1.11.1...v1.12.0)
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ await storage.getItem("foo:bar"); // or storage.getItem('/foo/bar')

👉 Check out the [the documentation](https://unstorage.unjs.io) for usage information.

## Nightly release channel

You can use the nightly release channel to try the latest changes in the `main` branch via [`unstorage-nightly`](https://www.npmjs.com/package/unstorage-nightly).

If directly using `unstorage` in your project:

```json
{
"devDependencies": {
"unstorage": "npm:unstorage-nightly"
}
}
```

If using `unstorage` via another tool in your project:

```json
{
"resolutions": {
"unstorage": "npm:unstorage-nightly"
}
}
```

## Contribution

- Clone repository
Expand Down
49 changes: 49 additions & 0 deletions docs/2.drivers/upstash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
icon: simple-icons:upstash
---

# Upstash

> Store data in an Upstash Redis database.

## Usage

::read-more{to="https://upstash.com/"}
Learn more about Upstash.
::

::note
Unstorage uses [`@upstash/redis`](https://github.com/upstash/upstash-redis) internally to connect to Upstash Redis.
::

To use it, you will need to install `@upstash/redis` in your project:

:pm-install{name="@upstash/redis"}

Usage with Upstash Redis:

```js
import { createStorage } from "unstorage";
import upstashDriver from "unstorage/drivers/upstash";

const storage = createStorage({
driver: upstashDriver({
base: "unstorage",
// url: "", // or set UPSTASH_REDIS_REST_URL env
// token: "", // or set UPSTASH_REDIS_REST_TOKEN env
}),
});
```

**Options:**

- `base`: Optional prefix to use for all keys. Can be used for namespacing.
- `url`: The REST URL for your Upstash Redis database. Find it in [the Upstash Redis console](https://console.upstash.com/redis/). Driver uses `UPSTASH_REDIS_REST_URL` environment by default.
- `token`: The REST token for authentication with your Upstash Redis database. Find it in [the Upstash Redis console](https://console.upstash.com/redis/). Driver uses `UPSTASH_REDIS_REST_TOKEN` environment by default.
- `ttl`: Default TTL for all items in **seconds**.

See [@upstash/redis documentation](https://upstash.com/docs/redis/sdks/ts/overview) for all available options.

**Transaction options:**

- `ttl`: Supported for `setItem(key, value, { ttl: number /* seconds */ })`
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export default unjs({
"unicorn/prefer-ternary": 0,
"unicorn/prefer-string-raw": 0,
"@typescript-eslint/no-empty-object-type": 0,
"unicorn/prefer-global-this": 0, // window. usage
},
});
54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unstorage",
"version": "1.12.0",
"version": "1.13.1",
"description": "Universal Storage Layer",
"repository": "unjs/unstorage",
"license": "MIT",
Expand Down Expand Up @@ -45,60 +45,60 @@
},
"dependencies": {
"anymatch": "^3.1.3",
"chokidar": "^4.0.1",
"chokidar": "^3.6.0",
"citty": "^0.1.6",
"destr": "^2.0.3",
"h3": "^1.13.0",
"listhen": "^1.9.0",
"lru-cache": "^10.4.3",
"mri": "^1.2.0",
"node-fetch-native": "^1.6.4",
"ofetch": "^1.4.1",
"ufo": "^1.5.4"
},
"devDependencies": {
"@azure/app-configuration": "^1.7.0",
"@azure/cosmos": "^4.1.1",
"@azure/data-tables": "^13.2.2",
"@azure/app-configuration": "^1.8.0",
"@azure/cosmos": "^4.2.0",
"@azure/data-tables": "^13.3.0",
"@azure/identity": "^4.5.0",
"@azure/keyvault-secrets": "^4.9.0",
"@azure/storage-blob": "^12.25.0",
"@capacitor/preferences": "^6.0.2",
"@cloudflare/workers-types": "^4.20241011.0",
"@azure/storage-blob": "^12.26.0",
"@capacitor/preferences": "^6.0.3",
"@cloudflare/workers-types": "^4.20241205.0",
"@netlify/blobs": "^8.1.0",
"@planetscale/database": "^1.19.0",
"@types/ioredis-mock": "^8.2.5",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.7.6",
"@types/node": "^22.10.1",
"@upstash/redis": "^1.34.3",
"@vercel/kv": "^3.0.0",
"@vitejs/plugin-vue": "^5.1.4",
"@vitest/coverage-v8": "^2.1.3",
"@vue/compiler-sfc": "^3.5.12",
"azurite": "^3.32.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vitest/coverage-v8": "^2.1.8",
"@vue/compiler-sfc": "^3.5.13",
"azurite": "^3.33.0",
"changelogen": "^0.5.7",
"eslint": "^9.12.0",
"eslint-config-unjs": "^0.4.1",
"eslint": "^9.16.0",
"eslint-config-unjs": "^0.4.2",
"fake-indexeddb": "^6.0.0",
"idb-keyval": "^6.2.1",
"ioredis": "^5.4.1",
"ioredis-mock": "^8.9.0",
"jiti": "^2.3.3",
"jiti": "^2.4.1",
"jsdom": "^25.0.1",
"mitata": "^1.0.10",
"mitata": "^1.0.20",
"monaco-editor": "^0.52.0",
"mongodb": "^6.9.0",
"mongodb": "^6.11.0",
"mongodb-memory-server": "^10.1.2",
"msw": "^1.3.4",
"prettier": "^3.3.3",
"msw": "^1.3.5",
"prettier": "^3.4.2",
"types-cloudflare-worker": "^1.2.0",
"typescript": "^5.6.3",
"typescript": "^5.7.2",
"unbuild": "^2.0.0",
"vite": "^5.4.9",
"vitest": "^2.1.3",
"vue": "^3.5.12"
"vite": "^6.0.3",
"vitest": "^2.1.8",
"vue": "^3.5.13"
},
"peerDependencies": {
"@azure/app-configuration": "^1.7.0",
"@azure/app-configuration": "^1.8.0",
"@azure/cosmos": "^4.1.1",
"@azure/data-tables": "^13.2.2",
"@azure/identity": "^4.5.0",
Expand Down Expand Up @@ -153,5 +153,5 @@
"optional": true
}
},
"packageManager": "pnpm@9.12.2"
"packageManager": "pnpm@9.14.4"
}
Loading