@upstash/redis 0.1.3 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -32
- package/dist/main/client.d.ts +6 -10
- package/dist/main/client.js +135 -197
- package/dist/main/index-cjs.d.ts +1 -0
- package/dist/main/index-cjs.js +120 -0
- package/dist/main/{type.d.ts → types.d.ts} +1 -11
- package/dist/main/{type.js → types.js} +0 -1
- package/dist/module/client.d.ts +6 -10
- package/dist/module/client.js +135 -197
- package/dist/module/index.d.ts +1 -2
- package/dist/module/index.js +1 -2
- package/dist/module/{type.d.ts → types.d.ts} +1 -11
- package/dist/module/types.js +1 -0
- package/package.json +14 -23
- package/src/client.ts +147 -222
- package/src/index-cjs.ts +117 -0
- package/src/index.ts +2 -2
- package/src/{type.ts → types.ts} +1 -11
- package/tsconfig.json +8 -6
- package/tsconfig.module.json +3 -2
- package/dist/main/client.d.ts.map +0 -1
- package/dist/main/client.js.map +0 -1
- package/dist/main/index.d.ts +0 -4
- package/dist/main/index.d.ts.map +0 -1
- package/dist/main/index.js +0 -13
- package/dist/main/index.js.map +0 -1
- package/dist/main/type.d.ts.map +0 -1
- package/dist/main/type.js.map +0 -1
- package/dist/module/client.d.ts.map +0 -1
- package/dist/module/client.js.map +0 -1
- package/dist/module/index.d.ts.map +0 -1
- package/dist/module/index.js.map +0 -1
- package/dist/module/type.d.ts.map +0 -1
- package/dist/module/type.js +0 -2
- package/dist/module/type.js.map +0 -1
- package/dist/umd/upstash-redis.js +0 -1
- package/webpack.config.js +0 -34
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ An HTTP/REST based Redis client built on top of [Upstash REST API](https://docs.
|
|
|
9
9
|
It is the only connectionless (HTTP based) Redis client and designed for:
|
|
10
10
|
|
|
11
11
|
- Serverless functions (AWS Lambda ...)
|
|
12
|
-
- Cloudflare Workers (see [the example](https://github.com/upstash/upstash-redis/tree/master/examples/workers
|
|
12
|
+
- Cloudflare Workers (see [the example](https://github.com/upstash/upstash-redis/tree/master/examples/cloudflare-workers))
|
|
13
13
|
- Fastly Compute@Edge
|
|
14
14
|
- Next.js, Jamstack ...
|
|
15
15
|
- Client side web/mobile applications
|
|
@@ -56,36 +56,8 @@ import { set } from '@upstash/redis';
|
|
|
56
56
|
})();
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
> If you define `UPSTASH_REDIS_REST_URL` and` UPSTASH_REDIS_REST_TOKEN` environment variables, you can
|
|
59
|
+
> If you define `UPSTASH_REDIS_REST_URL` and` UPSTASH_REDIS_REST_TOKEN` environment variables, you can skip the auth().
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
## Docs
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
import upstash from '@upstash/redis';
|
|
67
|
-
|
|
68
|
-
const redis = upstash({
|
|
69
|
-
url: 'UPSTASH_REDIS_REST_URL',
|
|
70
|
-
token: 'UPSTASH_REDIS_REST_TOKEN',
|
|
71
|
-
edgeUrl: 'UPSTASH_REDIS_EDGE_URL',
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
(async () => {
|
|
75
|
-
try {
|
|
76
|
-
// the below reads using edge url
|
|
77
|
-
const { data, error, metadata } = await redis.get('key');
|
|
78
|
-
if (error) throw error;
|
|
79
|
-
console.log(data);
|
|
80
|
-
// -> null | string
|
|
81
|
-
console.log(metadata);
|
|
82
|
-
// -> { edge: boolean, cache: null | 'miss' | 'hit' }
|
|
83
|
-
|
|
84
|
-
// the below reads using REST url (non-edge)
|
|
85
|
-
const get1 = await redis.get('key', { edge: false });
|
|
86
|
-
if (get1.error) throw get1.error;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error(error);
|
|
89
|
-
}
|
|
90
|
-
})();
|
|
91
|
-
```
|
|
63
|
+
See [the documentation](https://docs.upstash.com/features/javascriptsdk) for details.
|
package/dist/main/client.d.ts
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { ClientObjectProps, Upstash } from './
|
|
1
|
+
import { ClientObjectProps, Upstash } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a Upstash Redis instance
|
|
4
4
|
*
|
|
5
5
|
* @constructor
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {string}
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {string} [options.token] - database rest token
|
|
11
|
-
* @param {string} [options.edgeUrl] - database rest edge url
|
|
12
|
-
* @param {string} [options.readFromEdge] - database rest read from edge
|
|
6
|
+
* @param {Object} options
|
|
7
|
+
* @param {string} [options.url]
|
|
8
|
+
* @param {string} [options.token]
|
|
9
|
+
* @param {Object} [options.requestOptions]
|
|
13
10
|
*
|
|
14
11
|
* @example
|
|
15
12
|
* ```js
|
|
16
13
|
* import upstash from '@upstash/redis'
|
|
17
14
|
*
|
|
18
15
|
* const redis1 = upstash('url', token);
|
|
19
|
-
* const redis2 = upstash({ url: '', token: '',
|
|
16
|
+
* const redis2 = upstash({ url: '', token: '', requestOptions: {} });
|
|
20
17
|
* ```
|
|
21
18
|
*/
|
|
22
19
|
declare function upstash(options?: ClientObjectProps): Upstash;
|
|
23
20
|
declare function upstash(url?: string, token?: string): Upstash;
|
|
24
21
|
export default upstash;
|
|
25
|
-
//# sourceMappingURL=client.d.ts.map
|