@saltcorn/server 0.8.6-beta.16 → 0.8.6-beta.17
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 +8 -8
- package/serve.js +24 -0
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.8.6-beta.
|
|
3
|
+
"version": "0.8.6-beta.17",
|
|
4
4
|
"description": "Server app for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@saltcorn/base-plugin": "0.8.6-beta.
|
|
10
|
-
"@saltcorn/builder": "0.8.6-beta.
|
|
11
|
-
"@saltcorn/data": "0.8.6-beta.
|
|
12
|
-
"@saltcorn/admin-models": "0.8.6-beta.
|
|
13
|
-
"@saltcorn/filemanager": "0.8.6-beta.
|
|
14
|
-
"@saltcorn/markup": "0.8.6-beta.
|
|
15
|
-
"@saltcorn/sbadmin2": "0.8.6-beta.
|
|
9
|
+
"@saltcorn/base-plugin": "0.8.6-beta.17",
|
|
10
|
+
"@saltcorn/builder": "0.8.6-beta.17",
|
|
11
|
+
"@saltcorn/data": "0.8.6-beta.17",
|
|
12
|
+
"@saltcorn/admin-models": "0.8.6-beta.17",
|
|
13
|
+
"@saltcorn/filemanager": "0.8.6-beta.17",
|
|
14
|
+
"@saltcorn/markup": "0.8.6-beta.17",
|
|
15
|
+
"@saltcorn/sbadmin2": "0.8.6-beta.17",
|
|
16
16
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
17
17
|
"@socket.io/sticky": "^1.0.1",
|
|
18
18
|
"adm-zip": "0.5.10",
|
package/serve.js
CHANGED
|
@@ -8,6 +8,7 @@ const runScheduler = require("@saltcorn/data/models/scheduler");
|
|
|
8
8
|
const User = require("@saltcorn/data/models/user");
|
|
9
9
|
const Plugin = require("@saltcorn/data/models/plugin");
|
|
10
10
|
const db = require("@saltcorn/data/db");
|
|
11
|
+
const { getConfigFile, configFilePath } = require("@saltcorn/data/db/connect");
|
|
11
12
|
const {
|
|
12
13
|
getState,
|
|
13
14
|
init_multi_tenant,
|
|
@@ -49,11 +50,33 @@ const {
|
|
|
49
50
|
} = require("@saltcorn/admin-models/models/tenant");
|
|
50
51
|
const { auto_backup_now } = require("@saltcorn/admin-models/models/backup");
|
|
51
52
|
const Snapshot = require("@saltcorn/admin-models/models/snapshot");
|
|
53
|
+
const { writeFileSync } = require("fs");
|
|
52
54
|
|
|
53
55
|
const take_snapshot = async () => {
|
|
54
56
|
return await Snapshot.take_if_changed();
|
|
55
57
|
};
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Ensure the cfg file has a jwt_secret
|
|
61
|
+
*/
|
|
62
|
+
const ensureJwtSecret = () => {
|
|
63
|
+
const cfg = getConfigFile();
|
|
64
|
+
if (cfg && !cfg.jwt_secret) {
|
|
65
|
+
try {
|
|
66
|
+
const newSecret = require("crypto").randomBytes(64).toString("hex");
|
|
67
|
+
cfg.jwt_secret = newSecret;
|
|
68
|
+
writeFileSync(configFilePath, JSON.stringify(cfg, null, 2));
|
|
69
|
+
db.connectObj.jwt_secret = newSecret;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.log(
|
|
72
|
+
`Unable to set a jwt_secret: ${
|
|
73
|
+
error.message ? error.message : "Unknown error"
|
|
74
|
+
}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
57
80
|
// helpful https://gist.github.com/jpoehls/2232358
|
|
58
81
|
/**
|
|
59
82
|
* @param {object} opts
|
|
@@ -195,6 +218,7 @@ module.exports =
|
|
|
195
218
|
dev,
|
|
196
219
|
...appargs
|
|
197
220
|
} = {}) => {
|
|
221
|
+
ensureJwtSecret();
|
|
198
222
|
process.on("unhandledRejection", (reason, p) => {
|
|
199
223
|
console.error(reason, "Unhandled Rejection at Promise");
|
|
200
224
|
});
|