@upstash/redis 0.1.7 → 0.1.8
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/dist/main/client.js +35 -31
- package/dist/module/client.js +35 -31
- package/package.json +1 -1
- package/tsconfig.json +2 -2
- package/tsconfig.module.json +1 -1
package/dist/main/client.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -21,38 +30,33 @@ function parseOptions(url, token, requestOptions = {}) {
|
|
|
21
30
|
/**
|
|
22
31
|
* Fetch
|
|
23
32
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const res = await (0, isomorphic_unfetch_1.default)(options.url, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
body: JSON.stringify(parts),
|
|
32
|
-
headers: {
|
|
33
|
-
Authorization: `Bearer ${options.token}`,
|
|
34
|
-
...options.requestOptions?.headers,
|
|
35
|
-
},
|
|
36
|
-
...options.requestOptions,
|
|
37
|
-
});
|
|
38
|
-
const data = await res.json();
|
|
39
|
-
if (!res.ok) {
|
|
40
|
-
if (data.error)
|
|
41
|
-
throw data.error;
|
|
42
|
-
throw `Upstash failed with (${res.status}): ${JSON.stringify(data, null, 2)}`;
|
|
33
|
+
function fetchData(options, ...parts) {
|
|
34
|
+
var _a;
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
if (!options.url) {
|
|
37
|
+
throw 'Database url not found?';
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
try {
|
|
40
|
+
const res = yield (0, isomorphic_unfetch_1.default)(options.url, Object.assign({ method: 'POST', body: JSON.stringify(parts), headers: Object.assign({ Authorization: `Bearer ${options.token}` }, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.headers) }, options.requestOptions));
|
|
41
|
+
const data = yield res.json();
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
if (data.error)
|
|
44
|
+
throw data.error;
|
|
45
|
+
throw `Upstash failed with (${res.status}): ${JSON.stringify(data, null, 2)}`;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
data: data.result,
|
|
49
|
+
error: null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
return {
|
|
54
|
+
data: null,
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
error: err,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
56
60
|
}
|
|
57
61
|
function upstash(url, token) {
|
|
58
62
|
const options = parseOptions(url, token);
|
package/dist/module/client.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import fetch from 'isomorphic-unfetch';
|
|
2
11
|
/**
|
|
3
12
|
* Parse Options
|
|
@@ -16,38 +25,33 @@ function parseOptions(url, token, requestOptions = {}) {
|
|
|
16
25
|
/**
|
|
17
26
|
* Fetch
|
|
18
27
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const res = await fetch(options.url, {
|
|
25
|
-
method: 'POST',
|
|
26
|
-
body: JSON.stringify(parts),
|
|
27
|
-
headers: {
|
|
28
|
-
Authorization: `Bearer ${options.token}`,
|
|
29
|
-
...options.requestOptions?.headers,
|
|
30
|
-
},
|
|
31
|
-
...options.requestOptions,
|
|
32
|
-
});
|
|
33
|
-
const data = await res.json();
|
|
34
|
-
if (!res.ok) {
|
|
35
|
-
if (data.error)
|
|
36
|
-
throw data.error;
|
|
37
|
-
throw `Upstash failed with (${res.status}): ${JSON.stringify(data, null, 2)}`;
|
|
28
|
+
function fetchData(options, ...parts) {
|
|
29
|
+
var _a;
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (!options.url) {
|
|
32
|
+
throw 'Database url not found?';
|
|
38
33
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
try {
|
|
35
|
+
const res = yield fetch(options.url, Object.assign({ method: 'POST', body: JSON.stringify(parts), headers: Object.assign({ Authorization: `Bearer ${options.token}` }, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.headers) }, options.requestOptions));
|
|
36
|
+
const data = yield res.json();
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
if (data.error)
|
|
39
|
+
throw data.error;
|
|
40
|
+
throw `Upstash failed with (${res.status}): ${JSON.stringify(data, null, 2)}`;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
data: data.result,
|
|
44
|
+
error: null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return {
|
|
49
|
+
data: null,
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
error: err,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
51
55
|
}
|
|
52
56
|
function upstash(url, token) {
|
|
53
57
|
const options = parseOptions(url, token);
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"exclude": ["./**/dist", "node_modules"],
|
|
4
4
|
"compilerOptions": {
|
|
5
5
|
"declaration": true,
|
|
6
|
-
"lib": ["
|
|
6
|
+
"lib": ["ES2015", "DOM"],
|
|
7
7
|
"module": "CommonJS",
|
|
8
8
|
"rootDir": "src",
|
|
9
9
|
"outDir": "dist/main",
|
|
10
|
-
"target": "
|
|
10
|
+
"target": "ES2015",
|
|
11
11
|
"strict": true,
|
|
12
12
|
"moduleResolution": "Node",
|
|
13
13
|
"forceConsistentCasingInFileNames": true,
|