Skip to content

Commit

Permalink
Merge branch 'main' into pr/JoaoPedroAS51/221
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 7, 2023
2 parents 9d6a36a + 0e6e023 commit 6c3b4c2
Show file tree
Hide file tree
Showing 31 changed files with 2,969 additions and 2,212 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: [ "main" ]

permissions:
contents: read

jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- name: Fix lint issues
run: pnpm run lint:fix
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9
with:
commit-message: 'chore: apply automated lint fixes'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ tmp
/drivers
/test.*
__*
.vercel
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

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.8.0

[compare changes](https://github.com/unjs/unstorage/compare/v1.7.0...v1.8.0)

### 🚀 Enhancements

- Experimental operation batching ([#240](https://github.com/unjs/unstorage/pull/240))
- **cloudflare-kv:** Support `base` option for keys ([#261](https://github.com/unjs/unstorage/pull/261))
- `cloudflare-r2-binding` driver ([#235](https://github.com/unjs/unstorage/pull/235))

### 🩹 Fixes

- Add missing `cloudflareR2Binding` to the `builtinDrivers` ([48d6842](https://github.com/unjs/unstorage/commit/48d6842))

### 📖 Documentation

- Fix typo ([#252](https://github.com/unjs/unstorage/pull/252))

### 🏡 Chore

- Update dev dependencies ([ba44aed](https://github.com/unjs/unstorage/commit/ba44aed))

### ✅ Tests

- Add test for `github` driver ([#259](https://github.com/unjs/unstorage/pull/259))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))
- Hebilicious ([@Hebilicious](http://github.com/Hebilicious))
- Alex Duval ([@xlanex6](http://github.com/xlanex6))

## v1.7.0

[compare changes](https://github.com/unjs/unstorage/compare/v1.6.1...v1.7.0)
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion docs/content/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ We usually choose one or more storage backends based on our use-cases such as fi
- Binary and raw value support
- State [snapshots](/utils#snapshots) and hydration
- Storage watcher
- HTTP Storage with [built-in server](/server)
- HTTP Storage with [built-in server](/http-server)
21 changes: 19 additions & 2 deletions docs/content/2.usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Gets the value of a key in storage. Resolves to either a javascript primitive va
await storage.getItem("foo:bar");
```

### `getItems(items, opts)`

(Experimental) Gets the value of a multiple keys in storage in parallel.

Each item in array can be either a string or an object with`{ key, options? }` format.

Returned value is a Promise resolving to an array of objects with `{ key, value }` format.

### `getItemRaw(key, opts?)`

**Note:** This is an experimental feature. Please check [unjs/unstorage#142](https://github.com/unjs/unstorage/issues/142) for more information.
Expand All @@ -77,6 +85,14 @@ If value is `undefined`, it is same as calling `removeItem(key)`.
await storage.setItem("foo:bar", "baz");
```

### `setItems(items, opts)`

(Experimental) Add/Update items in parallel to the storage.

Each item in `items` array should be in `{ key, value, options? }` format.

Returned value is a Promise resolving to an array of objects with `{ key, value }` format.

### `setItemRaw(key, value, opts?)`

**Note:** This is an experimental feature. Please check [unjs/unstorage#142](https://github.com/unjs/unstorage/issues/142) for more information.
Expand All @@ -89,12 +105,13 @@ If value is `undefined`, it is same as calling `removeItem(key)`.
await storage.setItemRaw("data/test.bin", new Uint8Array([1, 2, 3]));
```

### `removeItem(key, opts = { removeMeta = true })`
### `removeItem(key, opts = { removeMeta = false })`

Remove a value (and it's meta) from storage.

```js
await storage.removeItem("foo:bar");
await storage.removeItem("foo:bar", { removeMeta: true });
// same as await storage.removeItem("foo:bar", true);
```

### `getMeta(key, opts = { nativeOnly? })`
Expand Down
1 change: 1 addition & 0 deletions docs/content/6.drivers/cloudflare-kv-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ const storage = createStorage({
**Options:**

- `binding`: KV binding or name of namespace. Default is `STORAGE`.
- `base`: Adds prefix to all stored keys
1 change: 1 addition & 0 deletions docs/content/6.drivers/cloudflare-kv-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const storage = createStorage({
- `apiKey`: API key generated on the "My Account" page of the Cloudflare console. May be used along with `email` to authenticate in place of `apiToken`.
- `userServiceKey`: A special Cloudflare API key good for a restricted set of endpoints. Always begins with "v1.0-", may vary in length. May be used to authenticate in place of `apiToken` or `apiKey` and `email`.
- `apiURL`: Custom API URL. Default is `https://api.cloudflare.com`.
- `base`: Adds prefix to all stored keys

**Supported methods:**

Expand Down
29 changes: 29 additions & 0 deletions docs/content/6.drivers/cloudflare-r2-binding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# CloudFlare R2 (binding)

::alert
This is an experimental driver! This driver only works in a cloudflare worker environment and cannot be used in other runtime environments such as Node.js (r2-http driver is coming soon)
::

Store data in [Cloudflare R2](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/) buckets and access from worker bindings.

You need to create and assign a R2 bucket. See [R2 Bindings](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/#create-a-binding) for more information.

```js
import { createStorage } from "unstorage";
import cloudflareR2BindingDriver from "unstorage/drivers/cloudflare-r2-binding";

// Using binding name to be picked from globalThis
const storage = createStorage({
driver: cloudflareR2BindingDriver({ binding: "MY_BUCKET" }),
});

// Directly setting binding
const storage = createStorage({
driver: cloudflareR2BindingDriver({ binding: globalThis.MY_BUCKET }),
});
```

**Options:**

- `binding`: Bucket binding or name.
- `base`: Prefix all keys with base.
1 change: 1 addition & 0 deletions docs/content/6.drivers/vercel-kv.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const storage = createStorage({
// token: "<your secret token>", // KV_REST_API_TOKEN
// base: "test",
// env: "KV",
// ttl: 60, // in seconds
}),
});
```
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "nuxi preview"
},
"devDependencies": {
"@nuxt-themes/docus": "^1.12.3",
"@nuxt-themes/docus": "^1.14.3",
"@nuxtjs/plausible": "^0.2.1",
"nuxt": "^3.6.1"
"nuxt": "^3.6.2"
}
}
Loading

0 comments on commit 6c3b4c2

Please sign in to comment.