Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 23, 2024
1 parent bfbf423 commit f78ffc4
Show file tree
Hide file tree
Showing 38 changed files with 596 additions and 10,526 deletions.
47 changes: 47 additions & 0 deletions docs/.config/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# yaml-language-server: $schema=https://unpkg.com/undocs/schema/config.json
name: unstorage
shortDescription: Universal Key-Value Storage.
description: Unstorage is TypeScript library that provides an async key-value storage API with conventional features like multi driver mounting, watching, working with metadata and has 20+ built-in drivers.
github: unjs/unstorage
themeColor: amber
url: https://unstorage.unjs.io
redirects:
"/usage": "/getting-started/usage"
"/utils": "/getting-started/utils"
"/http-server": "/getting-started/http-server"
"/custom-driver": "/getting-started/custom-driver"
"/drivers/azure-app-configuration": "/divers/azure"
"/drivers/azure-cosmos": "/divers/azure"
"/drivers/azure-key-vault": "/divers/azure"
"/drivers/azure-storage-block": "/divers/azure"
"/drivers/azure-storage-table": "/divers/azure"
"/drivers/cloudflare-kv-binding": "/drivers/cloudflare"
"/drivers/cloudflare-kv-http": "/drivers/cloudflare"
"/drivers/cloudflare-r2-binding": "/drivers/cloudflare"
"/drivers/vercel-kv": "/drivers/vercel"
"/drivers/netlify-blobs": "/drivers/netlify"
"/drivers/localstorage": "/drivers/browser"
"/drivers/indexedb": "/drivers/browser"
"/drivers/session-storage": "/drivers/browser"
landing:
contributors: true
featuresTitle: A simple, small, and fast key-value storage library for JavaScript.
features:
- title: "Runtime Agnostic"
description: "Your code will work on any JavaScript runtime including Node.js, Bun, Deno and Workers."
icon: "i-material-symbols-lock-open-right-outline-rounded"
- title: "Built-in drivers"
description: "Unstorage is shipped with 20+ built-in drivers for different platforms: Memory (default), FS, Redis, Memory, MongoDB, CloudFlare, GitHub..."
icon: "i-material-symbols-usb"
- title: "Snapshots"
description: "Expand your server and add capabilities. Your codebase will scale with your project."
icon: "i-material-symbols-add-a-photo-outline"
- title: "Multi Storages"
description: "Unix-style driver mounting to combine storages on different mounts."
icon: "i-material-symbols-view-list-outline"
- title: "JSON friendly"
description: "Unstorage automatically serialization and deserialization JSON values."
icon: "i-material-symbols-magic-button"
- title: "Binary Support"
description: "Store binary and raw data like images, videos, audio files, etc."
icon: "i-material-symbols-audio-file"
File renamed without changes
2 changes: 0 additions & 2 deletions docs/.npmrc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Usage
---
icon: ph:book-open-duotone
---

Learn how to setup and use unstorage in your project.
# Getting Started

> Learn how to setup and use unstorage in your project.
## Introduction

Expand All @@ -10,21 +14,7 @@ We usually choose one or more storage backends based on our use-cases such as fi

Install [`unstorage`](https://npmjs.com/package/unstorage) npm package:

::code-group

```sh [npm]
npm install unstorage
```

```sh [Yarn]
yarn add unstorage
```

```sh [pnpm]
pnpm add unstorage
```

::
:pm-install{name="unstorage"}

## Usage

Expand Down Expand Up @@ -260,7 +250,7 @@ storage.getMounts("cache:sub", { parents: true });
// => [{ base: "cache:sub", driver }, { base: "cache:", driver }, { base: "", driver }]
```

## Generic Types
## Generic types

**Type `getItem` return value:**

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Extra Utilities
---
icon: et:tools-2
---

Unstorage exposes several utilities. You can individually import them and add only needed bytes to your bundle.
# Utilities

> Unstorage exposes several utilities. You can individually import them and add only needed bytes to your bundle.
## Namespace

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
icon: ic:baseline-http
---

# HTTP Server

We can expose unstorage instance to an http server to allow remote connections.
> We can expose unstorage instance to an http server to allow remote connections.
Request url is mapped to key and method/body mapped to function. See below for supported http methods.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
icon: carbon:area-custom
---

# Custom Driver

It is possible to extend `unstorage` by creating a custom driver.
> It is possible to extend `unstorage` by creating a custom driver.
Explore [src/drivers](https://github.com/unjs/unstorage/tree/main/src/drivers) to inspire how to implement them. Methods can

Expand Down Expand Up @@ -28,12 +32,10 @@ const storage = createStorage({
```

Some important notes:
::list{type="warning"}

- Keys should be normalized following `foo:bar` convention
- Remove any open watcher and handlers in `dispose()`
- Returning a promise is optional, you can return a direct value (see [memory driver](https://github.com/unjs/unstorage/blob/main/src/drivers/memory.ts))
- You don't have acces to the mount base
- Value returned by `getItem` can be a serializable `object` or `string`
- When setting `watch` method, unstorage default handler will be disabled. You are responsible to emit event on `getItem`, `setItem` and `removeItem`.
::
13 changes: 13 additions & 0 deletions docs/2.drivers/0.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
----
icon: icon-park-outline:hard-disk
---

# Drivers

> Unstorage has several built-in drivers
See next sections for guide about using each driver.

::read-more{to="/guide#mountmountpoint-driver"}
See [`driver.mount()`] to learn about how to
::
Loading

0 comments on commit f78ffc4

Please sign in to comment.