@wxn0brp/db 0.5.5 → 0.5.6
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/client/database.d.ts +1 -1
- package/dist/client/database.js +21 -2
- package/dist/client/graph.d.ts +1 -1
- package/dist/client/graph.js +21 -2
- package/package.json +1 -1
package/dist/client/database.js
CHANGED
|
@@ -9,7 +9,25 @@ import serializeFunctions from "./function.js";
|
|
|
9
9
|
class DataBaseRemote {
|
|
10
10
|
remote;
|
|
11
11
|
constructor(remote) {
|
|
12
|
-
|
|
12
|
+
if (typeof remote === "string") {
|
|
13
|
+
const urlObj = new URL(remote);
|
|
14
|
+
const name = urlObj.username;
|
|
15
|
+
const auth = urlObj.password;
|
|
16
|
+
if (!name || !auth)
|
|
17
|
+
throw new Error("Invalid remote database");
|
|
18
|
+
urlObj.username = "";
|
|
19
|
+
urlObj.password = "";
|
|
20
|
+
const url = urlObj.toString().slice(0, -1);
|
|
21
|
+
this.remote = {
|
|
22
|
+
name,
|
|
23
|
+
url,
|
|
24
|
+
auth
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else
|
|
28
|
+
this.remote = remote;
|
|
29
|
+
if (this.remote.url.endsWith("/"))
|
|
30
|
+
this.remote.url = this.remote.url.slice(0, -1);
|
|
13
31
|
}
|
|
14
32
|
/**
|
|
15
33
|
* Make a request to the remote database.
|
|
@@ -21,7 +39,8 @@ class DataBaseRemote {
|
|
|
21
39
|
params: processed.data,
|
|
22
40
|
keys: processed.keys
|
|
23
41
|
};
|
|
24
|
-
const
|
|
42
|
+
const url = this.remote.url + "/db/" + type;
|
|
43
|
+
const res = await ky.post(url, {
|
|
25
44
|
json: data,
|
|
26
45
|
headers: {
|
|
27
46
|
"Authorization": this.remote.auth
|
package/dist/client/graph.d.ts
CHANGED
package/dist/client/graph.js
CHANGED
|
@@ -10,7 +10,25 @@ class GraphRemote {
|
|
|
10
10
|
* Create a new database instance.
|
|
11
11
|
*/
|
|
12
12
|
constructor(remote) {
|
|
13
|
-
|
|
13
|
+
if (typeof remote === "string") {
|
|
14
|
+
const urlObj = new URL(remote);
|
|
15
|
+
const name = urlObj.username;
|
|
16
|
+
const auth = urlObj.password;
|
|
17
|
+
if (!name || !auth)
|
|
18
|
+
throw new Error("Invalid remote database");
|
|
19
|
+
urlObj.username = "";
|
|
20
|
+
urlObj.password = "";
|
|
21
|
+
const url = urlObj.toString().slice(0, -1);
|
|
22
|
+
this.remote = {
|
|
23
|
+
name,
|
|
24
|
+
url,
|
|
25
|
+
auth
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else
|
|
29
|
+
this.remote = remote;
|
|
30
|
+
if (this.remote.url.endsWith("/"))
|
|
31
|
+
this.remote.url = this.remote.url.slice(0, -1);
|
|
14
32
|
}
|
|
15
33
|
/**
|
|
16
34
|
* Make a request to the remote database.
|
|
@@ -20,7 +38,8 @@ class GraphRemote {
|
|
|
20
38
|
db: this.remote.name,
|
|
21
39
|
params
|
|
22
40
|
};
|
|
23
|
-
const
|
|
41
|
+
const url = this.remote.url + "/db/" + type;
|
|
42
|
+
const res = await ky.post(url, {
|
|
24
43
|
json: data,
|
|
25
44
|
headers: {
|
|
26
45
|
"Authorization": this.remote.auth
|
package/package.json
CHANGED