esa-cli 0.0.2-beta.10 → 0.0.2-beta.13
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/commands/commit/index.js +26 -115
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/routineUtils.js +276 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/deploy/helper.js +40 -61
- package/dist/commands/deploy/index.js +90 -188
- package/dist/commands/deployments/delete.js +32 -22
- package/dist/commands/deployments/index.js +2 -2
- package/dist/commands/deployments/list.js +22 -38
- package/dist/commands/dev/build.js +3 -3
- package/dist/commands/dev/doProcess.js +5 -5
- package/dist/commands/dev/ew2/cacheService.js +33 -0
- package/dist/commands/dev/ew2/devEntry.js +2 -1
- package/dist/commands/dev/ew2/devPack.js +22 -11
- package/dist/commands/dev/ew2/kvService.js +27 -0
- package/dist/commands/dev/ew2/mock/cache.js +99 -15
- package/dist/commands/dev/ew2/mock/kv.js +142 -21
- package/dist/commands/dev/ew2/server.js +162 -27
- package/dist/commands/dev/index.js +14 -15
- package/dist/commands/dev/mockWorker/devPack.js +16 -7
- package/dist/commands/dev/mockWorker/server.js +7 -6
- package/dist/commands/domain/add.js +2 -2
- package/dist/commands/domain/delete.js +7 -7
- package/dist/commands/domain/index.js +2 -2
- package/dist/commands/domain/list.js +10 -10
- package/dist/commands/init/helper.js +87 -13
- package/dist/commands/init/index.js +461 -57
- package/dist/commands/init/template.jsonc +34 -0
- package/dist/commands/lang.js +2 -2
- package/dist/commands/login/index.js +57 -7
- package/dist/commands/logout.js +5 -5
- package/dist/commands/route/add.js +138 -49
- package/dist/commands/route/delete.js +33 -27
- package/dist/commands/route/helper.js +124 -0
- package/dist/commands/route/index.js +2 -2
- package/dist/commands/route/list.js +56 -17
- package/dist/commands/routine/delete.js +2 -2
- package/dist/commands/routine/index.js +2 -2
- package/dist/commands/routine/list.js +9 -21
- package/dist/commands/site/index.js +1 -1
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +55 -19
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +25 -15
- package/dist/docs/Commands_zh_CN.md +12 -2
- package/dist/docs/eslint-config-en.md +1 -0
- package/dist/docs/eslint-config.md +73 -0
- package/dist/docs/init-command-quick-test.md +208 -0
- package/dist/docs/init-command-test-guide.md +598 -0
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +261 -17
- package/dist/index.js +17 -12
- package/dist/libs/api.js +32 -9
- package/dist/libs/apiService.js +258 -85
- package/dist/libs/git/index.js +8 -4
- package/dist/libs/interface.js +0 -1
- package/dist/libs/logger.js +63 -7
- package/dist/libs/service.js +2 -2
- package/dist/libs/templates/index.js +1 -1
- package/dist/utils/checkAssetsExist.js +80 -0
- package/dist/utils/checkDevPort.js +3 -17
- package/dist/utils/checkEntryFileExist.js +10 -0
- package/dist/utils/checkIsRoutineCreated.js +16 -31
- package/dist/utils/checkVersion.js +1 -1
- package/dist/utils/compress.js +80 -0
- package/dist/utils/download.js +5 -5
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/index.js +71 -22
- package/dist/utils/installDeno.js +3 -3
- package/dist/utils/installEw2.js +7 -7
- package/dist/utils/openInBrowser.js +1 -1
- package/package.json +11 -6
|
@@ -7,15 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import path from 'path';
|
|
11
10
|
import fs from 'fs';
|
|
12
|
-
import
|
|
13
|
-
import devBuild from '../build.js';
|
|
11
|
+
import path from 'path';
|
|
14
12
|
import t from '../../../i18n/index.js';
|
|
15
|
-
import
|
|
16
|
-
import { getRoot, getDirName } from '../../../utils/fileUtils/base.js';
|
|
13
|
+
import logger from '../../../libs/logger.js';
|
|
17
14
|
import { checkPort } from '../../../utils/checkDevPort.js';
|
|
15
|
+
import { getRoot, getDirName } from '../../../utils/fileUtils/base.js';
|
|
16
|
+
import { getDevConf } from '../../../utils/fileUtils/index.js';
|
|
18
17
|
import { EW2Path } from '../../../utils/installEw2.js';
|
|
18
|
+
import devBuild from '../build.js';
|
|
19
19
|
// 生成可用的Ew2端口
|
|
20
20
|
const generateEw2Port = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
let ew2port = 3322;
|
|
@@ -61,7 +61,7 @@ conf_path = "${erConfPath}"
|
|
|
61
61
|
]);
|
|
62
62
|
};
|
|
63
63
|
// 生成入口文件
|
|
64
|
-
const generateEntry = (id, projectEntry, userRoot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
const generateEntry = (id, projectEntry, userRoot, port) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
65
|
const __dirname = getDirName(import.meta.url);
|
|
66
66
|
const devDir = path.resolve(userRoot, '.dev');
|
|
67
67
|
const devEntry = path.resolve(devDir, `devEntry-${id}.js`);
|
|
@@ -81,7 +81,9 @@ const generateEntry = (id, projectEntry, userRoot) => __awaiter(void 0, void 0,
|
|
|
81
81
|
const destPath = path.resolve(mockDevDir, file);
|
|
82
82
|
yield fs.promises.copyFile(srcPath, destPath);
|
|
83
83
|
}
|
|
84
|
-
return fs.promises.writeFile(devEntry, devEntryTempFile
|
|
84
|
+
return fs.promises.writeFile(devEntry, devEntryTempFile
|
|
85
|
+
.replace(/'\$userPath'/g, `'${projectEntry.replace(/\\/g, '/')}'`)
|
|
86
|
+
.replace(/\$userPort/g, `${port}`));
|
|
85
87
|
});
|
|
86
88
|
// 前期准备
|
|
87
89
|
const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -92,7 +94,7 @@ const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(
|
|
|
92
94
|
// @ts-ignore
|
|
93
95
|
global.id = id;
|
|
94
96
|
// 生成入口文件
|
|
95
|
-
yield generateEntry(id, entry, userRoot);
|
|
97
|
+
yield generateEntry(id, entry, userRoot, port);
|
|
96
98
|
// 生成 Ew2 配置
|
|
97
99
|
const ew2port = yield generateEw2Port();
|
|
98
100
|
yield writeEw2config(id, ew2port, userRoot);
|
|
@@ -127,13 +129,22 @@ const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(
|
|
|
127
129
|
}
|
|
128
130
|
return fs.promises.writeFile(configPath, `export default ${JSON.stringify(Object.assign(options, { [id]: currentOptions }))}`);
|
|
129
131
|
});
|
|
130
|
-
const devPack = (
|
|
132
|
+
const devPack = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
133
|
logger.ora.start('Processing...\n');
|
|
132
134
|
const userRoot = getRoot();
|
|
133
|
-
|
|
135
|
+
// Try to find config file in order of preference: .jsonc, .toml
|
|
136
|
+
const configFormats = ['esa.jsonc', 'esa.toml'];
|
|
137
|
+
let configPath = null;
|
|
138
|
+
for (const format of configFormats) {
|
|
139
|
+
const testPath = path.resolve(userRoot, format);
|
|
140
|
+
if (fs.existsSync(testPath)) {
|
|
141
|
+
configPath = testPath;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
134
145
|
let port, minify, localUpstream, entry;
|
|
135
146
|
let projectEntry = path.resolve(userRoot, 'src/index.js');
|
|
136
|
-
if (
|
|
147
|
+
if (configPath) {
|
|
137
148
|
port = getDevConf('port', 'dev', 18080);
|
|
138
149
|
minify = getDevConf('minify', 'dev', false);
|
|
139
150
|
localUpstream = getDevConf('localUpstream', 'dev', '');
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class EdgeKV {
|
|
2
|
+
constructor() { }
|
|
3
|
+
get(key, namespace) {
|
|
4
|
+
const store = EdgeKV.store.get(namespace);
|
|
5
|
+
if (!store || !store.has(key)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return store.get(key);
|
|
9
|
+
}
|
|
10
|
+
put(key, value, namespace) {
|
|
11
|
+
let store = EdgeKV.store.get(namespace);
|
|
12
|
+
if (!store) {
|
|
13
|
+
EdgeKV.store.set(namespace, new Map([[key, value]]));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
store.set(key, value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
delete(key, namespace) {
|
|
20
|
+
const store = EdgeKV.store.get(namespace);
|
|
21
|
+
if (!store)
|
|
22
|
+
return false;
|
|
23
|
+
return store.delete(key);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
EdgeKV.store = new Map();
|
|
27
|
+
export default EdgeKV;
|
|
@@ -1,31 +1,115 @@
|
|
|
1
1
|
class MockCache {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.
|
|
2
|
+
constructor(port) {
|
|
3
|
+
this.port = port;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
async put(reqOrUrl, response) {
|
|
7
|
+
if (arguments.length < 2) {
|
|
8
|
+
throw new TypeError(
|
|
9
|
+
`Failed to execute 'put' on 'cache': 2 arguments required, but only ${arguments.length} present.`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (!reqOrUrl) {
|
|
13
|
+
throw new TypeError(
|
|
14
|
+
"Failed to execute 'put' on 'cache': 2 arguments required, but only 0 present."
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (!(response instanceof Response)) {
|
|
18
|
+
throw new TypeError(
|
|
19
|
+
"Failed to execute 'put' on 'cache': Argument 2 is not of type Response."
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const body = await response.clone().text();
|
|
25
|
+
const headers = {};
|
|
26
|
+
response.headers.forEach((v, k) => (headers[k] = v));
|
|
27
|
+
|
|
28
|
+
const cacheControl = response.headers.get('Cache-Control') || '';
|
|
29
|
+
const ttl = this.parseTTL(cacheControl);
|
|
10
30
|
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
const key = this.normalizeKey(reqOrUrl);
|
|
32
|
+
const fetchRes = await fetch(
|
|
33
|
+
`http://localhost:${this.port}/mock_cache/put`,
|
|
34
|
+
{
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
key,
|
|
39
|
+
response: {
|
|
40
|
+
status: response.status,
|
|
41
|
+
headers,
|
|
42
|
+
body
|
|
43
|
+
},
|
|
44
|
+
ttl
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if (!fetchRes.ok) {
|
|
49
|
+
const error = await fetchRes.json();
|
|
50
|
+
throw new Error(error.error);
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
throw new Error(`Cache put failed: ${err.message}`);
|
|
55
|
+
}
|
|
13
56
|
}
|
|
14
57
|
|
|
15
|
-
async
|
|
16
|
-
|
|
58
|
+
async get(reqOrUrl) {
|
|
59
|
+
const key = this.normalizeKey(reqOrUrl);
|
|
60
|
+
const fetchRes = await fetch(
|
|
61
|
+
`http://localhost:${this.port}/mock_cache/get`,
|
|
62
|
+
{
|
|
63
|
+
method: 'POST',
|
|
64
|
+
headers: { 'Content-Type': 'application/json' },
|
|
65
|
+
body: JSON.stringify({
|
|
66
|
+
key
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
if (!fetchRes.ok) {
|
|
71
|
+
const error = await fetchRes.json();
|
|
72
|
+
throw new Error(error.error);
|
|
73
|
+
}
|
|
74
|
+
const res = await fetchRes.json();
|
|
75
|
+
if (res && res.success) {
|
|
76
|
+
return new Response(res.data.response.body, {
|
|
77
|
+
status: res.data.response.status,
|
|
78
|
+
headers: new Headers(res.data.response.headers)
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
17
83
|
}
|
|
18
84
|
|
|
19
85
|
async delete(reqOrUrl) {
|
|
20
|
-
|
|
86
|
+
const key = this.normalizeKey(reqOrUrl);
|
|
87
|
+
const fetchRes = await fetch(
|
|
88
|
+
`http://localhost:${this.port}/mock_cache/delete`,
|
|
89
|
+
{
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: { 'Content-Type': 'application/json' },
|
|
92
|
+
body: JSON.stringify({
|
|
93
|
+
key
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
if (!fetchRes.ok) {
|
|
98
|
+
const error = await fetchRes.json();
|
|
99
|
+
throw new Error(error.error);
|
|
100
|
+
}
|
|
101
|
+
const res = await fetchRes.json();
|
|
102
|
+
return res.success;
|
|
21
103
|
}
|
|
22
104
|
|
|
23
|
-
|
|
24
|
-
|
|
105
|
+
normalizeKey(input) {
|
|
106
|
+
const url = input instanceof Request ? input.url : input;
|
|
107
|
+
return url.replace(/^https:/i, 'http:');
|
|
25
108
|
}
|
|
26
109
|
|
|
27
|
-
|
|
28
|
-
|
|
110
|
+
parseTTL(cacheControl) {
|
|
111
|
+
const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
|
|
112
|
+
return maxAgeMatch ? parseInt(maxAgeMatch[1]) : 3600;
|
|
29
113
|
}
|
|
30
114
|
}
|
|
31
115
|
|
|
@@ -1,44 +1,165 @@
|
|
|
1
1
|
class EdgeKV {
|
|
2
|
+
static port = 0;
|
|
3
|
+
JS_RESPONSE_BUFFER_THRESHOLD = 64 * 1024;
|
|
2
4
|
constructor(options) {
|
|
5
|
+
if (!options || (!options.namespace && !options.namespaceId)) {
|
|
6
|
+
throw new TypeError(
|
|
7
|
+
'The argument to `EdgeKV` must be an object with a `namespace` or `namespaceId` field'
|
|
8
|
+
);
|
|
9
|
+
}
|
|
3
10
|
this.namespace = options.namespace;
|
|
4
|
-
this.allData = {};
|
|
5
11
|
}
|
|
6
12
|
|
|
7
|
-
async
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
async put(key, value) {
|
|
14
|
+
if (arguments.length < 2) {
|
|
15
|
+
throw new TypeError(
|
|
16
|
+
`Failed to execute 'put' on 'EdgeKV': 2 arguments required, but only ${arguments.length} present.`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
if (!key) {
|
|
20
|
+
throw new TypeError(
|
|
21
|
+
"Failed to execute 'put' on 'EdgeKV': 2 arguments required, but only 0 present."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (typeof key !== 'string') {
|
|
25
|
+
throw new TypeError(
|
|
26
|
+
`Failed to execute 'put' on 'EdgeKV': 1th argument must be a string.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
let body;
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
if (value.length > this.JS_RESPONSE_BUFFER_THRESHOLD) {
|
|
34
|
+
const encoder = new TextEncoder();
|
|
35
|
+
const encodedValue = encoder.encode(value);
|
|
36
|
+
|
|
37
|
+
body = new ReadableStream({
|
|
38
|
+
start(controller) {
|
|
39
|
+
controller.enqueue(encodedValue);
|
|
40
|
+
controller.close();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
body = value;
|
|
45
|
+
}
|
|
46
|
+
} else if (value instanceof Response) {
|
|
47
|
+
const resBody = await value.clone().text();
|
|
48
|
+
const headers = {};
|
|
49
|
+
value.headers.forEach((v, k) => (headers[k] = v));
|
|
50
|
+
body = JSON.stringify({
|
|
51
|
+
body: resBody,
|
|
52
|
+
headers,
|
|
53
|
+
status: value.status
|
|
54
|
+
});
|
|
55
|
+
} else if (
|
|
56
|
+
value instanceof ReadableStream ||
|
|
57
|
+
value instanceof ArrayBuffer ||
|
|
58
|
+
ArrayBuffer.isView(value)
|
|
59
|
+
) {
|
|
60
|
+
body = value;
|
|
61
|
+
} else {
|
|
62
|
+
throw new TypeError(
|
|
63
|
+
`Failed to execute 'put' on 'EdgeKV': 2nd argument should be one of string/Response/ArrayBuffer/ArrayBufferView/ReadableStream`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const fetchRes = await fetch(
|
|
68
|
+
`http://localhost:${EdgeKV.port}/mock_kv/put?key=${key}&namespace=${this.namespace}`,
|
|
69
|
+
{
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'Content-Type': 'application/json' },
|
|
72
|
+
body
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
if (!fetchRes.ok) {
|
|
76
|
+
const error = await fetchRes.json();
|
|
77
|
+
throw new Error(error.error);
|
|
78
|
+
}
|
|
10
79
|
return undefined;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
throw new Error(`Cache put failed: ${err.message}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async get(key, options) {
|
|
86
|
+
const isTypeValid = (ty) =>
|
|
87
|
+
typeof ty === 'string' &&
|
|
88
|
+
(ty === 'text' ||
|
|
89
|
+
ty === 'json' ||
|
|
90
|
+
ty === 'stream' ||
|
|
91
|
+
ty === 'arrayBuffer');
|
|
92
|
+
|
|
93
|
+
if (options && !isTypeValid(options?.type)) {
|
|
94
|
+
throw new TypeError(
|
|
95
|
+
"EdgeKV.get: 2nd optional argument must be an object with a 'type' field. The 'type' field specifies the format of the return value and must be a string of 'text', 'json', 'stream' or 'arrayBuffer'"
|
|
96
|
+
);
|
|
11
97
|
}
|
|
12
|
-
const value = namespaceData[key];
|
|
13
98
|
const type = options?.type || 'text';
|
|
99
|
+
const fetchRes = await fetch(
|
|
100
|
+
`http://localhost:${EdgeKV.port}/mock_kv/get?key=${key}&namespace=${this.namespace}`,
|
|
101
|
+
{
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: { 'Content-Type': 'application/json' }
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
// 判断是否存在key
|
|
107
|
+
let isGetFailed = false;
|
|
108
|
+
fetchRes.headers.forEach((v, k) => {
|
|
109
|
+
if (k === 'kv-get-empty') {
|
|
110
|
+
isGetFailed = true;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
if (isGetFailed) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
14
116
|
switch (type) {
|
|
15
117
|
case 'text':
|
|
16
|
-
return
|
|
118
|
+
return fetchRes.text();
|
|
17
119
|
case 'json':
|
|
18
120
|
try {
|
|
19
|
-
|
|
121
|
+
const value = await fetchRes.text();
|
|
122
|
+
const userObject = JSON.parse(value);
|
|
123
|
+
return userObject;
|
|
20
124
|
} catch (error) {
|
|
21
|
-
throw new
|
|
125
|
+
throw new TypeError(`Invalid JSON: ${err.message}`);
|
|
22
126
|
}
|
|
23
127
|
case 'arrayBuffer':
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
128
|
+
try {
|
|
129
|
+
const buffer = await fetchRes.arrayBuffer();
|
|
130
|
+
return buffer;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
throw new TypeError(
|
|
133
|
+
`Failed to read the response body into an ArrayBuffer: ${error.message}`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
case 'stream':
|
|
137
|
+
const stream = fetchRes.body;
|
|
138
|
+
return new ReadableStream({
|
|
139
|
+
start(controller) {
|
|
140
|
+
controller.enqueue(new TextEncoder().encode('hello world'));
|
|
141
|
+
controller.close();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
27
144
|
default:
|
|
28
|
-
throw new Error(
|
|
145
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
29
146
|
}
|
|
30
147
|
}
|
|
31
148
|
|
|
32
|
-
async put(key, value) {
|
|
33
|
-
const namespaceData = this.allData[this.namespace] || {};
|
|
34
|
-
namespaceData[key] = value;
|
|
35
|
-
this.allData[this.namespace] = namespaceData;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
149
|
async delete(key) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
150
|
+
const fetchRes = await fetch(
|
|
151
|
+
`http://localhost:${EdgeKV.port}/mock_kv/delete?key=${key}&namespace=${this.namespace}`,
|
|
152
|
+
{
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers: { 'Content-Type': 'application/json' }
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
if (!fetchRes.ok) {
|
|
158
|
+
const error = await fetchRes.json();
|
|
159
|
+
throw new Error(error.error);
|
|
160
|
+
}
|
|
161
|
+
const res = await fetchRes.json();
|
|
162
|
+
return res.success;
|
|
42
163
|
}
|
|
43
164
|
}
|
|
44
165
|
|