dbm-graph-api 1.1.11 → 1.1.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/package.json +2 -2
- package/src/dbm-graph-api/action/development/RestartDatabaseConnection.js +35 -0
- package/src/dbm-graph-api/action/development/RestartServer.js +52 -0
- package/src/dbm-graph-api/action/development/index.js +2 -0
- package/src/dbm-graph-api/action/index.js +2 -1
- package/src/dbm-graph-api/data/Breadcrumb.js +27 -0
- package/src/dbm-graph-api/data/index.js +3 -0
- package/src/dbm-graph-api/data/server/Status.js +23 -0
- package/src/dbm-graph-api/data/server/index.js +1 -0
- package/src/dbm-graph-api/index.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
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.741.0",
|
|
15
15
|
"@aws-sdk/s3-request-presigner": "^3.741.0",
|
|
16
|
-
"dbm": "^1.1.
|
|
16
|
+
"dbm": "^1.1.9",
|
|
17
17
|
"mime": "^4.0.6",
|
|
18
18
|
"sharp": "^0.33.5",
|
|
19
19
|
"ws": "^8.18.0"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import { exec } from 'node:child_process';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
export default class RestartServer extends Dbm.core.BaseObject {
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
|
|
9
|
+
this.item.requireProperty("salt", "]g[Qy-P?>KYEMf]Uf=:Hin5pA`oic6+s2wTn0&sqhdG)nFCZT)b[Osf5$w+0Z5a=");
|
|
10
|
+
this.item.requireProperty("restartKey", "c62b65e5eca50e92eb6c0f0cb1a74fc4ac43e0352b0d944389dddd27a2c62a47");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async performAction(aData, aEncodeSession) {
|
|
14
|
+
let returnObject = {};
|
|
15
|
+
|
|
16
|
+
let key = aData["key"];
|
|
17
|
+
|
|
18
|
+
let hash = createHash('sha256');
|
|
19
|
+
hash.update(key + this.item.salt);
|
|
20
|
+
let hashedKey = hash.digest('hex');
|
|
21
|
+
|
|
22
|
+
if(hashedKey !== this.item.restartKey) {
|
|
23
|
+
throw("Not allowed");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
27
|
+
database.restartConnection();
|
|
28
|
+
|
|
29
|
+
let connected = await database.testConnection();
|
|
30
|
+
|
|
31
|
+
returnObject["connected"] = connected;
|
|
32
|
+
|
|
33
|
+
return returnObject;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import { exec } from 'node:child_process';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
export default class RestartServer extends Dbm.core.BaseObject {
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
|
|
9
|
+
this.item.requireProperty("salt", "]g[Qy-P?>KYEMf]Uf=:Hin5pA`oic6+s2wTn0&sqhdG)nFCZT)b[Osf5$w+0Z5a=");
|
|
10
|
+
this.item.requireProperty("restartKey", "c62b65e5eca50e92eb6c0f0cb1a74fc4ac43e0352b0d944389dddd27a2c62a47");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async performAction(aData, aEncodeSession) {
|
|
14
|
+
let returnObject = {};
|
|
15
|
+
|
|
16
|
+
let key = aData["key"];
|
|
17
|
+
|
|
18
|
+
let hash = createHash('sha256');
|
|
19
|
+
hash.update(key + this.item.salt);
|
|
20
|
+
let hashedKey = hash.digest('hex');
|
|
21
|
+
|
|
22
|
+
if(hashedKey !== this.item.restartKey) {
|
|
23
|
+
throw("Not allowed");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let processName = process.env.name;
|
|
27
|
+
|
|
28
|
+
if(processName) {
|
|
29
|
+
returnObject["processName"] = processName;
|
|
30
|
+
|
|
31
|
+
setTimeout(function() {
|
|
32
|
+
exec('pm2 restart ' + processName, (error, stdout, stderr) => {
|
|
33
|
+
if (error) {
|
|
34
|
+
console.warn(`Failed to restart: ${error.message}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (stderr) {
|
|
38
|
+
console.warn(`PM2 stderr: ${stderr}`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}, 200);
|
|
42
|
+
|
|
43
|
+
returnObject["success"] = true;
|
|
44
|
+
returnObject["message"] = "Trying to restart";
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
returnObject["success"] = false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return returnObject;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -2,4 +2,5 @@ export {default as Example} from "./Example.js";
|
|
|
2
2
|
export {default as IncomingWebhook} from "./IncomingWebhook.js";
|
|
3
3
|
|
|
4
4
|
export * as cron from "./cron/index.js";
|
|
5
|
-
export * as admin from "./admin/index.js";
|
|
5
|
+
export * as admin from "./admin/index.js";
|
|
6
|
+
export * as development from "./development/index.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class Breadcrumb extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async getData(aData, aEncodeSession) {
|
|
9
|
+
let returnObject = {};
|
|
10
|
+
|
|
11
|
+
let url = aData["path"];
|
|
12
|
+
if(url[url.length-1] !== "/") {
|
|
13
|
+
url += "/";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
17
|
+
let urlObject = await database.getObjectByUrl(url);
|
|
18
|
+
|
|
19
|
+
if(urlObject) {
|
|
20
|
+
|
|
21
|
+
await aEncodeSession.encodeSingleWithTypes(urlObject.id, ["breadcrumb"]);
|
|
22
|
+
returnObject["id"] = urlObject.id;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return returnObject;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -3,6 +3,9 @@ export {default as UploadS3} from "./UploadS3.js";
|
|
|
3
3
|
export {default as FreeUrl} from "./FreeUrl.js";
|
|
4
4
|
export {default as SeoSummary} from "./SeoSummary.js";
|
|
5
5
|
export {default as AltText} from "./AltText.js";
|
|
6
|
+
export {default as Breadcrumb} from "./Breadcrumb.js";
|
|
7
|
+
|
|
8
|
+
export * as server from "./server/index.js";
|
|
6
9
|
|
|
7
10
|
import UploadS3 from "./UploadS3.js";
|
|
8
11
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class Status extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async getData(aData, aEncodeSession) {
|
|
9
|
+
let returnObject = {};
|
|
10
|
+
|
|
11
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
12
|
+
|
|
13
|
+
let connected = await database.testConnection();
|
|
14
|
+
|
|
15
|
+
if(!connected) {
|
|
16
|
+
throw("No database connection");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
returnObject["databaseConnection"] = connected;
|
|
20
|
+
|
|
21
|
+
return returnObject;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as Status} from "./Status.js";
|
|
@@ -181,9 +181,14 @@ export let registerDataFunction = function(aName, aDataFunction) {
|
|
|
181
181
|
|
|
182
182
|
let fullDataSetup = function() {
|
|
183
183
|
registerDataFunction("example", new DbmGraphApi.data.Example());
|
|
184
|
+
|
|
185
|
+
registerDataFunction("breadcrumb", new DbmGraphApi.data.Breadcrumb());
|
|
186
|
+
|
|
184
187
|
registerDataFunction("admin/freeUrl", new DbmGraphApi.data.FreeUrl());
|
|
185
188
|
registerDataFunction("admin/seoSummary", new DbmGraphApi.data.SeoSummary());
|
|
186
189
|
registerDataFunction("admin/altText", new DbmGraphApi.data.AltText());
|
|
190
|
+
|
|
191
|
+
registerDataFunction("server/status", new DbmGraphApi.data.server.Status());
|
|
187
192
|
}
|
|
188
193
|
|
|
189
194
|
export {fullDataSetup};
|
|
@@ -201,6 +206,9 @@ let fullActionSetup = function() {
|
|
|
201
206
|
registerActionFunction("incomingWebhook", new DbmGraphApi.action.IncomingWebhook());
|
|
202
207
|
registerActionFunction("cron/processActions", new DbmGraphApi.action.cron.ProcessActions());
|
|
203
208
|
registerActionFunction("admin/addAndProcessAction", new DbmGraphApi.action.admin.AddAndProcessAction());
|
|
209
|
+
|
|
210
|
+
registerActionFunction("development/restartServer", new DbmGraphApi.action.development.RestartServer());
|
|
211
|
+
registerActionFunction("development/restartDatabaseConnection", new DbmGraphApi.action.development.RestartDatabaseConnection());
|
|
204
212
|
}
|
|
205
213
|
|
|
206
214
|
export {fullActionSetup};
|