dbm-graph-api 1.0.1 → 1.0.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@aws-sdk/client-s3": "^3.693.0",
|
|
15
15
|
"@aws-sdk/s3-request-presigner": "^3.693.0",
|
|
16
|
-
"dbm": "^1.0.
|
|
16
|
+
"dbm": "^1.0.3",
|
|
17
17
|
"ws": "^8.18.0"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import DbmGraphApi from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class UrlRequest extends Dbm.core.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._encodedObjects = [];
|
|
9
|
+
this._responseData = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async requestUrl(aUrl) {
|
|
13
|
+
|
|
14
|
+
let url = aUrl;
|
|
15
|
+
|
|
16
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
17
|
+
let urlObject = await database.getObjectByUrl(url);
|
|
18
|
+
|
|
19
|
+
if(urlObject) {
|
|
20
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
21
|
+
encodeSession.outputController = this;
|
|
22
|
+
|
|
23
|
+
await encodeSession.encodeSingleWithTypes(urlObject.id, ["urlRequest"]);
|
|
24
|
+
encodeSession.destroy();
|
|
25
|
+
this._responseData = {"id": urlObject.id};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this._responseData = {"id": 0};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async requestRange(aSelects, aEncodes, aData) {
|
|
33
|
+
//METODO
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async requestItem(aId, aEncodes) {
|
|
37
|
+
//METODO
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async requestData(aFunctionName, aData) {
|
|
41
|
+
//METODO
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
outputEncodedData(aId, aData, aEncoding) {
|
|
45
|
+
console.log("UrlRequest::outputEncodedData");
|
|
46
|
+
|
|
47
|
+
this._encodedObjects.push({"id": aId, "data": aData, "encoding": aEncoding});
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getResponse() {
|
|
52
|
+
return {"objects": this._encodedObjects, "data": this._responseData};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
|
|
3
3
|
|
|
4
4
|
import DbmGraphApi from "../../index.js";
|
|
5
5
|
import Api from "./Api.js";
|
|
6
|
+
import UrlRequest from "./UrlRequest.js";
|
|
6
7
|
|
|
7
8
|
export {Api};
|
|
8
9
|
|
|
@@ -171,6 +172,24 @@ let setupEndpoints = function(aServer) {
|
|
|
171
172
|
//METODO: clear session from database
|
|
172
173
|
//METODO: clear cookie
|
|
173
174
|
});
|
|
175
|
+
|
|
176
|
+
aServer.get('/api/url', async function handler (aRequest, aReply) {
|
|
177
|
+
//console.log(aRequest);
|
|
178
|
+
|
|
179
|
+
let url = aRequest.query.url;
|
|
180
|
+
|
|
181
|
+
if(url[url.length-1] !== "/") {
|
|
182
|
+
url += "/";
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
console.log(url);
|
|
186
|
+
//METODO: check visibility in database
|
|
187
|
+
let request = new UrlRequest();
|
|
188
|
+
|
|
189
|
+
await request.requestUrl(url);
|
|
190
|
+
|
|
191
|
+
return request.getResponse();
|
|
192
|
+
});
|
|
174
193
|
|
|
175
194
|
//METODO: setup ranges
|
|
176
195
|
//METODO: setup edit
|