dbgate-api 5.5.4-alpha.4 → 5.5.4-alpha.8

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,7 +1,7 @@
1
1
  {
2
2
  "name": "dbgate-api",
3
3
  "main": "src/index.js",
4
- "version": "5.5.4-alpha.4",
4
+ "version": "5.5.4-alpha.8",
5
5
  "homepage": "https://dbgate.org/",
6
6
  "repository": {
7
7
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "compare-versions": "^3.6.0",
27
27
  "cors": "^2.8.5",
28
28
  "cross-env": "^6.0.3",
29
- "dbgate-datalib": "^5.5.4-alpha.4",
29
+ "dbgate-datalib": "^5.5.4-alpha.8",
30
30
  "dbgate-query-splitter": "^4.10.5",
31
- "dbgate-sqltree": "^5.5.4-alpha.4",
32
- "dbgate-tools": "^5.5.4-alpha.4",
31
+ "dbgate-sqltree": "^5.5.4-alpha.8",
32
+ "dbgate-tools": "^5.5.4-alpha.8",
33
33
  "debug": "^4.3.4",
34
34
  "diff": "^5.0.0",
35
35
  "diff2html": "^3.4.13",
@@ -68,6 +68,7 @@
68
68
  "start:dblogin": "env-cmd -f env/dblogin/.env node src/index.js --listen-api",
69
69
  "start:filedb": "env-cmd node src/index.js /home/jena/test/chinook/Chinook.db --listen-api",
70
70
  "start:storage": "env-cmd -f env/storage/.env node src/index.js --listen-api",
71
+ "start:storage:built": "env-cmd -f env/storage/.env cross-env DEVMODE= BUILTWEBMODE=1 node dist/bundle.js --listen-api",
71
72
  "start:singleconn": "env-cmd node src/index.js --server localhost --user root --port 3307 --engine mysql@dbgate-plugin-mysql --password test --listen-api",
72
73
  "ts": "tsc",
73
74
  "build": "webpack"
@@ -75,7 +76,7 @@
75
76
  "devDependencies": {
76
77
  "@types/fs-extra": "^9.0.11",
77
78
  "@types/lodash": "^4.14.149",
78
- "dbgate-types": "^5.5.4-alpha.4",
79
+ "dbgate-types": "^5.5.4-alpha.8",
79
80
  "env-cmd": "^10.1.0",
80
81
  "node-loader": "^1.0.2",
81
82
  "nodemon": "^2.0.2",
@@ -83,9 +83,16 @@ class OAuthProvider extends AuthProviderBase {
83
83
  )}&client_id=${process.env.OAUTH_CLIENT_ID}&client_secret=${process.env.OAUTH_CLIENT_SECRET}${scopeParam}`
84
84
  );
85
85
 
86
- const { access_token, refresh_token } = resp.data;
86
+ const { access_token, refresh_token, id_token } = resp.data;
87
87
 
88
- const payload = jwt.decode(access_token);
88
+ let payload = jwt.decode(access_token);
89
+
90
+ // Fallback to id_token in case the access_token is not a JWT
91
+ // https://www.oauth.com/oauth2-servers/access-tokens/
92
+ // https://github.com/dbgate/dbgate/issues/727
93
+ if (!payload && id_token) {
94
+ payload = jwt.decode(id_token);
95
+ }
89
96
 
90
97
  logger.info({ payload }, 'User payload returned from OAUTH');
91
98
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  module.exports = {
3
- version: '5.5.4-alpha.4',
4
- buildTime: '2024-10-01T10:23:19.199Z'
3
+ version: '5.5.4-alpha.8',
4
+ buildTime: '2024-10-03T07:59:47.603Z'
5
5
  };
package/src/index.js CHANGED
@@ -1,10 +1,15 @@
1
- const { setLogConfig, getLogger, setLoggerName } = require('dbgate-tools');
1
+ const { setLogConfig, getLogger, setLoggerName, extractErrorLogData } = require('dbgate-tools');
2
2
  const processArgs = require('./utility/processArgs');
3
3
  const fs = require('fs');
4
4
  const moment = require('moment');
5
5
  const path = require('path');
6
6
  const { logsdir, setLogsFilePath, getLogsFilePath } = require('./utility/directories');
7
- const { createLogger } = require('pinomin');
7
+
8
+ const logger = getLogger('apiIndex');
9
+
10
+ process.on('uncaughtException', err => {
11
+ logger.fatal(extractErrorLogData(err), 'Uncaught exception');
12
+ });
8
13
 
9
14
  if (processArgs.startProcess) {
10
15
  setLoggerName(processArgs.startProcess.replace(/Process$/, ''));
@@ -11,14 +11,8 @@ async function tableWriter({ connection, schemaName, pureName, driver, systemCon
11
11
  }
12
12
  const dbhan = systemConnection || (await connectUtility(driver, connection, 'write'));
13
13
 
14
- try {
15
- logger.info(`Connected.`);
16
- return await driver.writeTable(dbhan, { schemaName, pureName }, options);
17
- } finally {
18
- if (!systemConnection) {
19
- await driver.close(dbhan);
20
- }
21
- }
14
+ logger.info(`Connected.`);
15
+ return await driver.writeTable(dbhan, { schemaName, pureName }, options);
22
16
  }
23
17
 
24
18
  module.exports = tableWriter;
@@ -71,6 +71,9 @@ function packagedPluginsDir() {
71
71
  if (platformInfo.isDevMode) {
72
72
  return path.resolve(__dirname, '../../../../plugins');
73
73
  }
74
+ if (platformInfo.isBuiltWebMode) {
75
+ return path.resolve(__dirname, '../../plugins');
76
+ }
74
77
  if (platformInfo.isDocker) {
75
78
  return '/home/dbgate-docker/plugins';
76
79
  }
@@ -10,6 +10,7 @@ const isMac = platform === 'darwin';
10
10
  const isLinux = platform === 'linux';
11
11
  const isDocker = fs.existsSync('/home/dbgate-docker/public');
12
12
  const isDevMode = process.env.DEVMODE == '1';
13
+ const isBuiltWebMode = process.env.BUILTWEBMODE == '1';
13
14
  const isNpmDist = !!global['IS_NPM_DIST'];
14
15
  const isDbModel = !!global['IS_DB_MODEL'];
15
16
  const isForkedApi = processArgs.isForkedApi;