@xansql/bridge 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/package.json +6 -3
  2. package/server.js +8 -10
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@xansql/bridge",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
+ "type": "module",
4
5
  "description": "Xansql bridge",
5
6
  "author": "Devnax",
6
- "type": "module",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -13,6 +13,9 @@
13
13
  "type": "git",
14
14
  "url": "https://github.com/xansql/bridge.git"
15
15
  },
16
+ "peerDependencies": {
17
+ "@xansql/core": "*"
18
+ },
16
19
  "dependencies": {
17
20
  "securequ": "^1.1.19"
18
21
  },
@@ -34,4 +37,4 @@
34
37
  },
35
38
  "./package.json": "./package.json"
36
39
  }
37
- }
40
+ }
package/server.js CHANGED
@@ -1,4 +1,4 @@
1
- // import { XansqlError } from '@xansql/core';
1
+ import { XansqlError } from '@xansql/core';
2
2
  import { makeSecret, makePath } from './base.js';
3
3
  import { SecurequServer, crypto } from 'securequ';
4
4
 
@@ -13,11 +13,11 @@ class XansqlBridgeServer {
13
13
  const config = this.config;
14
14
  if (config.isAuthorized) {
15
15
  const isPermit = await config.isAuthorized(info);
16
- // if (!isPermit)
17
- // throw new XansqlError({
18
- // message: "isAuthorized denied for server initialization.",
19
- // model: info.model ? info.model.table : undefined,
20
- // });
16
+ if (!isPermit)
17
+ throw new XansqlError({
18
+ message: "isAuthorized denied for server initialization.",
19
+ model: info.model ? info.model.table : undefined,
20
+ });
21
21
  }
22
22
  }
23
23
  async initial() {
@@ -26,14 +26,12 @@ class XansqlBridgeServer {
26
26
  const config = this.config;
27
27
  const xansql = this.xansql;
28
28
  const secret = await makeSecret(this.xansql);
29
- const server = new SecurequServer(Object.assign(Object.assign({}, (config || {})), {
30
- clients: [
29
+ const server = new SecurequServer(Object.assign(Object.assign({}, (config || {})), { clients: [
31
30
  {
32
31
  origin: `*`,
33
32
  secret
34
33
  }
35
- ]
36
- }));
34
+ ] }));
37
35
  server.get(await makePath('find', xansql), async (req) => {
38
36
  const params = req.searchParams;
39
37
  await this.authorized({