acebase-server 1.17.0 → 1.18.0
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/bin/acebase-server.js +8 -0
- package/dist/cjs/cluster.js +2 -52
- package/dist/cjs/routes/data-schema-set.js +2 -2
- package/dist/cjs/routes/docs.js +1 -1
- package/dist/cjs/routes/meta-info.js +1 -1
- package/dist/cjs/server.js +1 -6
- package/dist/cjs/start.js +75 -9
- package/dist/esm/cluster.js +2 -50
- package/dist/esm/routes/data-schema-set.js +2 -2
- package/dist/esm/routes/docs.js +1 -1
- package/dist/esm/routes/meta-info.js +1 -1
- package/dist/esm/server.js +3 -3
- package/dist/esm/start.js +75 -9
- package/dist/types/cluster.d.ts +6 -1
- package/dist/types/routes/data-schema-set.d.ts +1 -0
- package/dist/types/settings/index.d.ts +2 -2
- package/package.json +6 -3
- package/src/routes/data-schema-set.yaml +4 -0
package/dist/cjs/cluster.js
CHANGED
|
@@ -1,57 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const acebase_1 = require("acebase");
|
|
4
|
-
const server_1 = require("./server");
|
|
5
|
-
const cluster = require("cluster");
|
|
6
|
-
const numCPUs = 2; //os.cpus().length;
|
|
7
1
|
/**
|
|
8
|
-
* Node.js cluster example. You can use this as a reference how to create an AceBaseServer cluster using Node.js'
|
|
9
|
-
* built-in cluster functionality.
|
|
10
2
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
3
|
+
* To run an AceBase server in a cluster and examples, please refer to this discussion:
|
|
4
|
+
* https://github.com/appy-one/acebase-server/discussions/83
|
|
13
5
|
*
|
|
14
6
|
*/
|
|
15
|
-
const dbname = 'default';
|
|
16
|
-
const options = { /* default options */}; // Load from cluster.config.js!
|
|
17
|
-
options.authentication = { enabled: false };
|
|
18
|
-
options.https = { enabled: false };
|
|
19
|
-
if (cluster.isMaster) {
|
|
20
|
-
// Startup master
|
|
21
|
-
console.log(`Starting database server cluster with ${numCPUs} workers`);
|
|
22
|
-
const master = new acebase_1.AceBase(dbname, options);
|
|
23
|
-
master.once('ready', () => {
|
|
24
|
-
console.log(`Master database server started on process ${process.pid}`);
|
|
25
|
-
});
|
|
26
|
-
for (let i = 0; i < numCPUs; i++) {
|
|
27
|
-
const worker = cluster.fork();
|
|
28
|
-
worker.on('disconnect', () => {
|
|
29
|
-
console.error(`worker ${worker.process.pid} disconnected`);
|
|
30
|
-
});
|
|
31
|
-
worker.on('message', (msg) => {
|
|
32
|
-
if (msg === 'acebase-server-shutdown') {
|
|
33
|
-
// We could handle shutdown message here to kill the worker safely, but we'll do it in the worker threads instead: see below
|
|
34
|
-
// worker.kill();
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
cluster.on('exit', (worker, code, signal) => {
|
|
39
|
-
console.error(`worker ${worker.process.pid} died`);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.log(`Worker ${process.pid} is running`);
|
|
44
|
-
const server = new server_1.AceBaseServer(dbname, options);
|
|
45
|
-
server.ready(() => {
|
|
46
|
-
console.log(`Worker database server started on process ${process.pid}`);
|
|
47
|
-
});
|
|
48
|
-
// Handle shutdown event to exit the worker process safely
|
|
49
|
-
server.on('shutdown', () => {
|
|
50
|
-
process.exit();
|
|
51
|
-
});
|
|
52
|
-
// Other option:
|
|
53
|
-
// process.on('acebase-server-shutdown', () => {
|
|
54
|
-
// process.exit();
|
|
55
|
-
// });
|
|
56
|
-
}
|
|
57
7
|
//# sourceMappingURL=cluster.js.map
|
|
@@ -17,8 +17,8 @@ const addRoute = (env) => {
|
|
|
17
17
|
// defines a schema
|
|
18
18
|
try {
|
|
19
19
|
const data = req.body;
|
|
20
|
-
const { path, schema } = data;
|
|
21
|
-
yield env.db.schema.set(path, schema);
|
|
20
|
+
const { path, schema, warnOnly = false } = data;
|
|
21
|
+
yield env.db.schema.set(path, schema, warnOnly);
|
|
22
22
|
res.contentType('application/json').send({ success: true });
|
|
23
23
|
}
|
|
24
24
|
catch (err) {
|
package/dist/cjs/routes/docs.js
CHANGED
|
@@ -19,7 +19,7 @@ const addRoute = (env) => {
|
|
|
19
19
|
info: {
|
|
20
20
|
title: 'AceBase Server',
|
|
21
21
|
description: 'AceBase Server API endpoint documentation and test environment. This documentation is available on the server because it is running in development mode. To disable this, set your NODE_ENV environment variable to production. Many endpoints require you to authenticate using Bearer authentication. Use the _/auth/{dbname}/signin_ endpoint to obtain an access token, then click the _Authorize_ button and paste your token into the input field. For more information about AceBase, see GitHub',
|
|
22
|
-
version: '1.
|
|
22
|
+
version: '1.18.0',
|
|
23
23
|
contact: {
|
|
24
24
|
name: 'AceBase API Support',
|
|
25
25
|
email: 'me@appy.one',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addRoute = void 0;
|
|
4
4
|
const os = require("os");
|
|
5
|
-
const SERVER_VERSION = '1.
|
|
5
|
+
const SERVER_VERSION = '1.18.0'; // Loaded from package.json by npm scripts
|
|
6
6
|
const addRoute = (env) => {
|
|
7
7
|
// Add info endpoint
|
|
8
8
|
env.router.get(`/info/${env.db.name}`, (req, res) => {
|
package/dist/cjs/server.js
CHANGED
|
@@ -78,13 +78,8 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
78
78
|
const dbOptions = {
|
|
79
79
|
logLevel: this.config.logLevel,
|
|
80
80
|
info: 'realtime database server',
|
|
81
|
-
|
|
82
|
-
storage: this.config.storage || {
|
|
83
|
-
path: this.config.path,
|
|
84
|
-
removeVoidProperties: true,
|
|
85
|
-
},
|
|
81
|
+
storage: Object.assign({ path: this.config.path, removeVoidProperties: true, ipc: this.config.ipc }, this.config.storage),
|
|
86
82
|
transactions: this.config.transactions,
|
|
87
|
-
ipc: this.config.ipc,
|
|
88
83
|
sponsor: this.config.sponsor,
|
|
89
84
|
logColors: this.config.logColors,
|
|
90
85
|
};
|
package/dist/cjs/start.js
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const server_1 = require("./server");
|
|
4
|
+
/*
|
|
5
|
+
|
|
6
|
+
Use environment variables or pass arguments to this script to start an AceBase server
|
|
7
|
+
instance from the command-line.
|
|
8
|
+
|
|
9
|
+
Command-line arguments format:
|
|
10
|
+
`npx acebase-server start DBNAME=mydb HOST=localhost PORT=3000`
|
|
11
|
+
You can use all variables mentioned below (without 'ACEBASE_' prefix)
|
|
12
|
+
|
|
13
|
+
All environment variables MUST be prefixed with 'ACEBASE_' (except for PORT if ACEBASE_PORT is not specified).
|
|
14
|
+
Currently available environment variables:
|
|
15
|
+
|
|
16
|
+
# File and network settings:
|
|
17
|
+
ACEBASE_DBNAME='mydb'
|
|
18
|
+
ACEBASE_DBPATH='.'
|
|
19
|
+
ACEBASE_HOST='localhost'
|
|
20
|
+
ACEBASE_PORT='3000'
|
|
21
|
+
ACEBASE_ROOT_PATH=''
|
|
22
|
+
|
|
23
|
+
# Transaction logging settings:
|
|
24
|
+
ACEBASE_TXLOG='true'
|
|
25
|
+
ACEBASE_TXDAYS='30'
|
|
26
|
+
|
|
27
|
+
# Auth settings:
|
|
28
|
+
ACEBASE_AUTH='true'
|
|
29
|
+
ACEBASE_AUTH_USER_SIGNUP='true'
|
|
30
|
+
ACEBASE_AUTH_DEFAULT_ACCESS_RULE='deny'
|
|
31
|
+
ACEBASE_AUTH_DEFAULT_ADMIN_PASSWORD=''
|
|
32
|
+
ACEBASE_AUTH_NEW_USER_RATE_LIMIT='0'
|
|
33
|
+
ACEBASE_AUTH_SEPARATE_DB='false'
|
|
34
|
+
ACEBASE_AUTH_TOKENS_EXPIRE='0'
|
|
35
|
+
|
|
36
|
+
# IPC configuration for single machine clusters
|
|
37
|
+
ACEBASE_IPC='socket'
|
|
38
|
+
|
|
39
|
+
# IPC configuration for multiple machine clusters (Make sure there is ONLY ONE 'master' instance)
|
|
40
|
+
ACEBASE_IPC_PORT='9163'
|
|
41
|
+
ACEBASE_IPC_HOST='ipc.example.com'
|
|
42
|
+
ACEBASE_IPC_ROLE='master'
|
|
43
|
+
ACEBASE_IPC_SSL='true'
|
|
44
|
+
ACEBASE_IPC_TOKEN='secret'
|
|
45
|
+
|
|
46
|
+
*/
|
|
4
47
|
// If one executes "node start.js [dbname=name] [host=ip] [port=nr]"
|
|
5
48
|
function getVariable(name, defaultValue) {
|
|
6
49
|
// Checks if an argument with the name was passed,
|
|
@@ -11,18 +54,23 @@ function getVariable(name, defaultValue) {
|
|
|
11
54
|
if (arg) {
|
|
12
55
|
return arg.split('=')[1];
|
|
13
56
|
}
|
|
14
|
-
|
|
57
|
+
const envName = `ACEBASE_${name}`;
|
|
58
|
+
if (typeof process.env[envName] !== 'undefined') {
|
|
59
|
+
return process.env[envName];
|
|
60
|
+
}
|
|
61
|
+
if (name === 'PORT' && typeof process.env[name] !== 'undefined') {
|
|
15
62
|
return process.env[name];
|
|
16
63
|
}
|
|
17
64
|
return defaultValue;
|
|
18
65
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
66
|
+
const options = {
|
|
67
|
+
host: getVariable('HOST', 'localhost'),
|
|
68
|
+
port: +getVariable('PORT', 3000),
|
|
69
|
+
path: getVariable('DBPATH', '.'),
|
|
70
|
+
rootPath: getVariable('ROOT_PATH', ''),
|
|
71
|
+
};
|
|
72
|
+
// Check if we should use a remote IPC server, let AceBase use a local IPC socket otherwise
|
|
23
73
|
const ipcPort = +getVariable('IPC_PORT', 0);
|
|
24
|
-
const rootPath = getVariable('ROOT_PATH', '');
|
|
25
|
-
const options = { host, port, path, rootPath };
|
|
26
74
|
if (ipcPort > 0) {
|
|
27
75
|
const role = getVariable('IPC_ROLE');
|
|
28
76
|
if (!['master', 'worker'].includes(role)) {
|
|
@@ -36,15 +84,33 @@ if (ipcPort > 0) {
|
|
|
36
84
|
role,
|
|
37
85
|
};
|
|
38
86
|
}
|
|
39
|
-
if (
|
|
87
|
+
else if (getVariable('IPC') === 'socket') {
|
|
88
|
+
// Use local IPC socket, will become default soon
|
|
89
|
+
options.ipc = 'socket';
|
|
90
|
+
}
|
|
91
|
+
// Check if transaction logging should be enabled (not enabled by default)
|
|
92
|
+
if (getVariable('TXLOG', 'false') === 'true' || +getVariable('TXLOG', 0) === 1) {
|
|
40
93
|
options.transactions = {
|
|
41
94
|
log: true,
|
|
42
95
|
maxAge: +getVariable('TXDAYS', 30),
|
|
43
96
|
};
|
|
44
97
|
}
|
|
45
|
-
if
|
|
98
|
+
// Check if authentication should be enabled (default)
|
|
99
|
+
if (getVariable('AUTH', 'true') === 'true' || +getVariable('AUTH', 1) === 1) {
|
|
100
|
+
options.authentication = {
|
|
101
|
+
enabled: true,
|
|
102
|
+
allowUserSignup: +getVariable('AUTH_USER_SIGNUP', 1) === 1,
|
|
103
|
+
defaultAccessRule: getVariable('AUTH_DEFAULT_ACCESS_RULE'),
|
|
104
|
+
defaultAdminPassword: getVariable('AUTH_DEFAULT_ADMIN_PASSWORD'),
|
|
105
|
+
newUserRateLimit: +getVariable('AUTH_NEW_USER_RATE_LIMIT', 0),
|
|
106
|
+
separateDb: getVariable('AUTH_SEPARATE_DB', false),
|
|
107
|
+
tokensExpire: +getVariable('AUTH_TOKENS_EXPIRE', 0), // No implemented yet
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
46
111
|
options.authentication = { enabled: false };
|
|
47
112
|
}
|
|
113
|
+
const dbname = getVariable('DBNAME', 'default');
|
|
48
114
|
const server = new server_1.AceBaseServer(dbname, options);
|
|
49
115
|
server.once('ready', () => {
|
|
50
116
|
var _a;
|
package/dist/esm/cluster.js
CHANGED
|
@@ -1,55 +1,7 @@
|
|
|
1
|
-
import { AceBase } from 'acebase';
|
|
2
|
-
import { AceBaseServer } from './server.js';
|
|
3
|
-
import * as cluster from 'cluster';
|
|
4
|
-
const numCPUs = 2; //os.cpus().length;
|
|
5
1
|
/**
|
|
6
|
-
* Node.js cluster example. You can use this as a reference how to create an AceBaseServer cluster using Node.js'
|
|
7
|
-
* built-in cluster functionality.
|
|
8
2
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
3
|
+
* To run an AceBase server in a cluster and examples, please refer to this discussion:
|
|
4
|
+
* https://github.com/appy-one/acebase-server/discussions/83
|
|
11
5
|
*
|
|
12
6
|
*/
|
|
13
|
-
const dbname = 'default';
|
|
14
|
-
const options = { /* default options */}; // Load from cluster.config.js!
|
|
15
|
-
options.authentication = { enabled: false };
|
|
16
|
-
options.https = { enabled: false };
|
|
17
|
-
if (cluster.isMaster) {
|
|
18
|
-
// Startup master
|
|
19
|
-
console.log(`Starting database server cluster with ${numCPUs} workers`);
|
|
20
|
-
const master = new AceBase(dbname, options);
|
|
21
|
-
master.once('ready', () => {
|
|
22
|
-
console.log(`Master database server started on process ${process.pid}`);
|
|
23
|
-
});
|
|
24
|
-
for (let i = 0; i < numCPUs; i++) {
|
|
25
|
-
const worker = cluster.fork();
|
|
26
|
-
worker.on('disconnect', () => {
|
|
27
|
-
console.error(`worker ${worker.process.pid} disconnected`);
|
|
28
|
-
});
|
|
29
|
-
worker.on('message', (msg) => {
|
|
30
|
-
if (msg === 'acebase-server-shutdown') {
|
|
31
|
-
// We could handle shutdown message here to kill the worker safely, but we'll do it in the worker threads instead: see below
|
|
32
|
-
// worker.kill();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
cluster.on('exit', (worker, code, signal) => {
|
|
37
|
-
console.error(`worker ${worker.process.pid} died`);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
console.log(`Worker ${process.pid} is running`);
|
|
42
|
-
const server = new AceBaseServer(dbname, options);
|
|
43
|
-
server.ready(() => {
|
|
44
|
-
console.log(`Worker database server started on process ${process.pid}`);
|
|
45
|
-
});
|
|
46
|
-
// Handle shutdown event to exit the worker process safely
|
|
47
|
-
server.on('shutdown', () => {
|
|
48
|
-
process.exit();
|
|
49
|
-
});
|
|
50
|
-
// Other option:
|
|
51
|
-
// process.on('acebase-server-shutdown', () => {
|
|
52
|
-
// process.exit();
|
|
53
|
-
// });
|
|
54
|
-
}
|
|
55
7
|
//# sourceMappingURL=cluster.js.map
|
|
@@ -5,8 +5,8 @@ export const addRoute = (env) => {
|
|
|
5
5
|
// defines a schema
|
|
6
6
|
try {
|
|
7
7
|
const data = req.body;
|
|
8
|
-
const { path, schema } = data;
|
|
9
|
-
await env.db.schema.set(path, schema);
|
|
8
|
+
const { path, schema, warnOnly = false } = data;
|
|
9
|
+
await env.db.schema.set(path, schema, warnOnly);
|
|
10
10
|
res.contentType('application/json').send({ success: true });
|
|
11
11
|
}
|
|
12
12
|
catch (err) {
|
package/dist/esm/routes/docs.js
CHANGED
|
@@ -14,7 +14,7 @@ export const addRoute = (env) => {
|
|
|
14
14
|
info: {
|
|
15
15
|
title: 'AceBase Server',
|
|
16
16
|
description: 'AceBase Server API endpoint documentation and test environment. This documentation is available on the server because it is running in development mode. To disable this, set your NODE_ENV environment variable to production. Many endpoints require you to authenticate using Bearer authentication. Use the _/auth/{dbname}/signin_ endpoint to obtain an access token, then click the _Authorize_ button and paste your token into the input field. For more information about AceBase, see GitHub',
|
|
17
|
-
version: '1.
|
|
17
|
+
version: '1.18.0',
|
|
18
18
|
contact: {
|
|
19
19
|
name: 'AceBase API Support',
|
|
20
20
|
email: 'me@appy.one',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as os from 'os';
|
|
2
|
-
const SERVER_VERSION = '1.
|
|
2
|
+
const SERVER_VERSION = '1.18.0'; // Loaded from package.json by npm scripts
|
|
3
3
|
export const addRoute = (env) => {
|
|
4
4
|
// Add info endpoint
|
|
5
5
|
env.router.get(`/info/${env.db.name}`, (req, res) => {
|
package/dist/esm/server.js
CHANGED
|
@@ -62,13 +62,13 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
62
62
|
const dbOptions = {
|
|
63
63
|
logLevel: this.config.logLevel,
|
|
64
64
|
info: 'realtime database server',
|
|
65
|
-
|
|
66
|
-
storage: this.config.storage || {
|
|
65
|
+
storage: {
|
|
67
66
|
path: this.config.path,
|
|
68
67
|
removeVoidProperties: true,
|
|
68
|
+
ipc: this.config.ipc,
|
|
69
|
+
...this.config.storage, // Allow overriding storage settings - allows using other db backends (typed, but undocumented)
|
|
69
70
|
},
|
|
70
71
|
transactions: this.config.transactions,
|
|
71
|
-
ipc: this.config.ipc,
|
|
72
72
|
sponsor: this.config.sponsor,
|
|
73
73
|
logColors: this.config.logColors,
|
|
74
74
|
};
|
package/dist/esm/start.js
CHANGED
|
@@ -1,4 +1,47 @@
|
|
|
1
1
|
import { AceBaseServer } from './server.js';
|
|
2
|
+
/*
|
|
3
|
+
|
|
4
|
+
Use environment variables or pass arguments to this script to start an AceBase server
|
|
5
|
+
instance from the command-line.
|
|
6
|
+
|
|
7
|
+
Command-line arguments format:
|
|
8
|
+
`npx acebase-server start DBNAME=mydb HOST=localhost PORT=3000`
|
|
9
|
+
You can use all variables mentioned below (without 'ACEBASE_' prefix)
|
|
10
|
+
|
|
11
|
+
All environment variables MUST be prefixed with 'ACEBASE_' (except for PORT if ACEBASE_PORT is not specified).
|
|
12
|
+
Currently available environment variables:
|
|
13
|
+
|
|
14
|
+
# File and network settings:
|
|
15
|
+
ACEBASE_DBNAME='mydb'
|
|
16
|
+
ACEBASE_DBPATH='.'
|
|
17
|
+
ACEBASE_HOST='localhost'
|
|
18
|
+
ACEBASE_PORT='3000'
|
|
19
|
+
ACEBASE_ROOT_PATH=''
|
|
20
|
+
|
|
21
|
+
# Transaction logging settings:
|
|
22
|
+
ACEBASE_TXLOG='true'
|
|
23
|
+
ACEBASE_TXDAYS='30'
|
|
24
|
+
|
|
25
|
+
# Auth settings:
|
|
26
|
+
ACEBASE_AUTH='true'
|
|
27
|
+
ACEBASE_AUTH_USER_SIGNUP='true'
|
|
28
|
+
ACEBASE_AUTH_DEFAULT_ACCESS_RULE='deny'
|
|
29
|
+
ACEBASE_AUTH_DEFAULT_ADMIN_PASSWORD=''
|
|
30
|
+
ACEBASE_AUTH_NEW_USER_RATE_LIMIT='0'
|
|
31
|
+
ACEBASE_AUTH_SEPARATE_DB='false'
|
|
32
|
+
ACEBASE_AUTH_TOKENS_EXPIRE='0'
|
|
33
|
+
|
|
34
|
+
# IPC configuration for single machine clusters
|
|
35
|
+
ACEBASE_IPC='socket'
|
|
36
|
+
|
|
37
|
+
# IPC configuration for multiple machine clusters (Make sure there is ONLY ONE 'master' instance)
|
|
38
|
+
ACEBASE_IPC_PORT='9163'
|
|
39
|
+
ACEBASE_IPC_HOST='ipc.example.com'
|
|
40
|
+
ACEBASE_IPC_ROLE='master'
|
|
41
|
+
ACEBASE_IPC_SSL='true'
|
|
42
|
+
ACEBASE_IPC_TOKEN='secret'
|
|
43
|
+
|
|
44
|
+
*/
|
|
2
45
|
// If one executes "node start.js [dbname=name] [host=ip] [port=nr]"
|
|
3
46
|
function getVariable(name, defaultValue) {
|
|
4
47
|
// Checks if an argument with the name was passed,
|
|
@@ -9,18 +52,23 @@ function getVariable(name, defaultValue) {
|
|
|
9
52
|
if (arg) {
|
|
10
53
|
return arg.split('=')[1];
|
|
11
54
|
}
|
|
12
|
-
|
|
55
|
+
const envName = `ACEBASE_${name}`;
|
|
56
|
+
if (typeof process.env[envName] !== 'undefined') {
|
|
57
|
+
return process.env[envName];
|
|
58
|
+
}
|
|
59
|
+
if (name === 'PORT' && typeof process.env[name] !== 'undefined') {
|
|
13
60
|
return process.env[name];
|
|
14
61
|
}
|
|
15
62
|
return defaultValue;
|
|
16
63
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
64
|
+
const options = {
|
|
65
|
+
host: getVariable('HOST', 'localhost'),
|
|
66
|
+
port: +getVariable('PORT', 3000),
|
|
67
|
+
path: getVariable('DBPATH', '.'),
|
|
68
|
+
rootPath: getVariable('ROOT_PATH', ''),
|
|
69
|
+
};
|
|
70
|
+
// Check if we should use a remote IPC server, let AceBase use a local IPC socket otherwise
|
|
21
71
|
const ipcPort = +getVariable('IPC_PORT', 0);
|
|
22
|
-
const rootPath = getVariable('ROOT_PATH', '');
|
|
23
|
-
const options = { host, port, path, rootPath };
|
|
24
72
|
if (ipcPort > 0) {
|
|
25
73
|
const role = getVariable('IPC_ROLE');
|
|
26
74
|
if (!['master', 'worker'].includes(role)) {
|
|
@@ -34,15 +82,33 @@ if (ipcPort > 0) {
|
|
|
34
82
|
role,
|
|
35
83
|
};
|
|
36
84
|
}
|
|
37
|
-
if (
|
|
85
|
+
else if (getVariable('IPC') === 'socket') {
|
|
86
|
+
// Use local IPC socket, will become default soon
|
|
87
|
+
options.ipc = 'socket';
|
|
88
|
+
}
|
|
89
|
+
// Check if transaction logging should be enabled (not enabled by default)
|
|
90
|
+
if (getVariable('TXLOG', 'false') === 'true' || +getVariable('TXLOG', 0) === 1) {
|
|
38
91
|
options.transactions = {
|
|
39
92
|
log: true,
|
|
40
93
|
maxAge: +getVariable('TXDAYS', 30),
|
|
41
94
|
};
|
|
42
95
|
}
|
|
43
|
-
if
|
|
96
|
+
// Check if authentication should be enabled (default)
|
|
97
|
+
if (getVariable('AUTH', 'true') === 'true' || +getVariable('AUTH', 1) === 1) {
|
|
98
|
+
options.authentication = {
|
|
99
|
+
enabled: true,
|
|
100
|
+
allowUserSignup: +getVariable('AUTH_USER_SIGNUP', 1) === 1,
|
|
101
|
+
defaultAccessRule: getVariable('AUTH_DEFAULT_ACCESS_RULE'),
|
|
102
|
+
defaultAdminPassword: getVariable('AUTH_DEFAULT_ADMIN_PASSWORD'),
|
|
103
|
+
newUserRateLimit: +getVariable('AUTH_NEW_USER_RATE_LIMIT', 0),
|
|
104
|
+
separateDb: getVariable('AUTH_SEPARATE_DB', false),
|
|
105
|
+
tokensExpire: +getVariable('AUTH_TOKENS_EXPIRE', 0), // No implemented yet
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
44
109
|
options.authentication = { enabled: false };
|
|
45
110
|
}
|
|
111
|
+
const dbname = getVariable('DBNAME', 'default');
|
|
46
112
|
const server = new AceBaseServer(dbname, options);
|
|
47
113
|
server.once('ready', () => {
|
|
48
114
|
server.debug.log(`AceBase server running`);
|
package/dist/types/cluster.d.ts
CHANGED
|
@@ -152,7 +152,7 @@ export type AceBaseServerSettings = Partial<{
|
|
|
152
152
|
/**
|
|
153
153
|
* IPC settings for pm2 or cloud-based clusters. BETA stage, see https://github.com/appy-one/acebase-ipc-server
|
|
154
154
|
*/
|
|
155
|
-
ipc: IPCClientSettings;
|
|
155
|
+
ipc: IPCClientSettings | 'socket';
|
|
156
156
|
/**
|
|
157
157
|
* Allows overriding of default storage settings used by the database. ALPHA stage
|
|
158
158
|
*/
|
|
@@ -186,7 +186,7 @@ export declare class AceBaseServerConfig {
|
|
|
186
186
|
readonly auth: AceBaseServerAuthenticationSettings;
|
|
187
187
|
readonly email: AceBaseServerEmailSettings;
|
|
188
188
|
readonly transactions: AceBaseServerTransactionSettings;
|
|
189
|
-
readonly ipc:
|
|
189
|
+
readonly ipc: AceBaseServerSettings['ipc'];
|
|
190
190
|
readonly storage?: AceBaseStorageSettings;
|
|
191
191
|
readonly sponsor: boolean;
|
|
192
192
|
readonly logColors: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "acebase-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "AceBase realtime database server (webserver endpoint to allow remote connections)",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"types": "./dist/types/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"acebase-server": "./bin/acebase-server.js"
|
|
17
|
+
},
|
|
15
18
|
"private": false,
|
|
16
19
|
"repository": "github:appy-one/acebase-server",
|
|
17
20
|
"scripts": {
|
|
@@ -61,8 +64,8 @@
|
|
|
61
64
|
"author": "Ewout Stortenbeker <me@appy.one> (http://appy.one)",
|
|
62
65
|
"license": "MIT",
|
|
63
66
|
"dependencies": {
|
|
64
|
-
"acebase": "^1.
|
|
65
|
-
"acebase-core": "^1.
|
|
67
|
+
"acebase": "^1.29.0",
|
|
68
|
+
"acebase-core": "^1.27.1",
|
|
66
69
|
"express": "^4.17.1",
|
|
67
70
|
"socket.io": "^4.5.0",
|
|
68
71
|
"swagger-jsdoc": "^6.1.0",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
type: string
|
|
33
33
|
description: When given, tests this schema definition against the passed value instead of ones defined in the database
|
|
34
34
|
example: "{ name: string, stats?: { size: number, created: Date, modified: Date, deleted?: Date } }"
|
|
35
|
+
warnOnly:
|
|
36
|
+
type: boolean
|
|
37
|
+
description: whether to issue warnings for failing schema checks instead of denying writes. This allows you to add schemas to an existing database and testdrive them without enforcing them yet. Default is `false`
|
|
38
|
+
example: false
|
|
35
39
|
required:
|
|
36
40
|
- path
|
|
37
41
|
- schema
|