@tachybase/data-source 0.23.58 → 1.0.18
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/lib/data-source-manager.js +7 -9
- package/lib/data-source.js +3 -1
- package/package.json +7 -7
|
@@ -39,15 +39,13 @@ const _DataSourceManager = class _DataSourceManager {
|
|
|
39
39
|
}
|
|
40
40
|
middleware() {
|
|
41
41
|
return async (ctx, next) => {
|
|
42
|
-
const name = ctx.get("x-data-source");
|
|
43
|
-
if (name) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
ctx.throw(`data source ${name} does not exist`);
|
|
50
|
-
}
|
|
42
|
+
const name = ctx.get("x-data-source") || "main";
|
|
43
|
+
if (this.dataSources.has(name)) {
|
|
44
|
+
const ds = this.dataSources.get(name);
|
|
45
|
+
ctx.dataSource = ds;
|
|
46
|
+
return ds.middleware(this.middlewares)(ctx, next);
|
|
47
|
+
} else {
|
|
48
|
+
ctx.throw(`data source ${name} does not exist`);
|
|
51
49
|
}
|
|
52
50
|
await next();
|
|
53
51
|
};
|
package/lib/data-source.js
CHANGED
|
@@ -80,7 +80,9 @@ const _DataSource = class _DataSource extends import_events.default {
|
|
|
80
80
|
if (this.resourceManager.isDefined(resourceName)) {
|
|
81
81
|
return next();
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
const splitResult = resourceName.split(".");
|
|
84
|
+
const collectionName = splitResult[0];
|
|
85
|
+
if (!this.collectionManager.hasCollection(collectionName)) {
|
|
84
86
|
return next();
|
|
85
87
|
}
|
|
86
88
|
this.resourceManager.define({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/data-source",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"jsonwebtoken": "^8.5.1",
|
|
12
12
|
"koa-compose": "^4.1.0",
|
|
13
13
|
"lodash": "4.17.21",
|
|
14
|
-
"@tachybase/acl": "0.
|
|
15
|
-
"@tachybase/actions": "0.
|
|
16
|
-
"@tachybase/cache": "0.
|
|
17
|
-
"@tachybase/database": "0.
|
|
18
|
-
"@tachybase/utils": "0.
|
|
19
|
-
"@tachybase/resourcer": "0.
|
|
14
|
+
"@tachybase/acl": "1.0.18",
|
|
15
|
+
"@tachybase/actions": "1.0.18",
|
|
16
|
+
"@tachybase/cache": "1.0.18",
|
|
17
|
+
"@tachybase/database": "1.0.18",
|
|
18
|
+
"@tachybase/utils": "1.0.18",
|
|
19
|
+
"@tachybase/resourcer": "1.0.18"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/koa": "^2.15.0",
|