vona-module-a-core 5.0.18 → 5.0.20
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/dist/index.js +100 -2
- package/package.json +3 -3
- package/dist/.metadata/index.js +0 -28
- package/dist/.metadata/this.js +0 -2
- package/dist/bean/meta.static.js +0 -14
- package/dist/bean/middleware.gate.js +0 -22
- package/dist/bean/middlewareSystem.notfound.js +0 -41
- package/dist/bean/middlewareSystem.overrideMethod.js +0 -26
- package/dist/lib/core.js +0 -7
- package/dist/lib/index.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { BeanInfo, BeanBase, BeanScopeBase } from 'vona';
|
|
2
|
+
import { Scope } from 'vona-module-a-bean';
|
|
3
|
+
import { Meta } from 'vona-module-a-meta';
|
|
4
|
+
import { BeanStaticBase } from 'vona-module-a-static';
|
|
5
|
+
import { Middleware, MiddlewareSystem, Aspect } from 'vona-module-a-aspect';
|
|
6
|
+
import overrideMethodImport from 'koa-override';
|
|
7
|
+
|
|
8
|
+
var _dec$4, _dec2$4, _class$4;
|
|
9
|
+
let MetaStatic = (_dec$4 = Meta(), _dec2$4 = BeanInfo({
|
|
10
|
+
module: "a-core"
|
|
11
|
+
}), _dec$4(_class$4 = _dec2$4(_class$4 = class MetaStatic extends BeanStaticBase {}) || _class$4) || _class$4);
|
|
12
|
+
|
|
13
|
+
var _dec$3, _dec2$3, _class$3;
|
|
14
|
+
let MiddlewareGate = (_dec$3 = Middleware({
|
|
15
|
+
global: true
|
|
16
|
+
}), _dec2$3 = BeanInfo({
|
|
17
|
+
module: "a-core"
|
|
18
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class MiddlewareGate extends BeanBase {
|
|
19
|
+
async execute(options, next) {
|
|
20
|
+
// check gate
|
|
21
|
+
if (!this.app.bean.onion.checkOnionOptionsMeta(options.gate)) {
|
|
22
|
+
this.app.throw(403);
|
|
23
|
+
}
|
|
24
|
+
// next
|
|
25
|
+
return next();
|
|
26
|
+
}
|
|
27
|
+
}) || _class$3) || _class$3);
|
|
28
|
+
|
|
29
|
+
var _dec$2, _dec2$2, _class$2;
|
|
30
|
+
let MiddlewareSystemNotfound = (_dec$2 = MiddlewareSystem({
|
|
31
|
+
dependencies: 'a-logger:httpLog'
|
|
32
|
+
}), _dec2$2 = BeanInfo({
|
|
33
|
+
module: "a-core"
|
|
34
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class MiddlewareSystemNotfound extends BeanBase {
|
|
35
|
+
async execute(options, next) {
|
|
36
|
+
const ctx = this.ctx;
|
|
37
|
+
await next();
|
|
38
|
+
if (ctx.status !== 404 || ctx.body) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// set status first, make sure set body not set status
|
|
43
|
+
ctx.status = 404;
|
|
44
|
+
if (ctx.acceptJSON) {
|
|
45
|
+
ctx.body = {
|
|
46
|
+
message: 'Not Found'
|
|
47
|
+
};
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const notFoundHtml = '<h1>404 Not Found</h1>';
|
|
51
|
+
|
|
52
|
+
// notfound handler is unimplemented
|
|
53
|
+
if (options.pageUrl && ctx.path === options.pageUrl) {
|
|
54
|
+
ctx.body = `${notFoundHtml}<p><pre><code>config.notfound.pageUrl(${options.pageUrl})</code></pre> is unimplemented</p>`;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (options.pageUrl) {
|
|
58
|
+
ctx.realStatus = 404;
|
|
59
|
+
ctx.redirect(options.pageUrl);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
ctx.body = notFoundHtml;
|
|
63
|
+
}
|
|
64
|
+
}) || _class$2) || _class$2);
|
|
65
|
+
|
|
66
|
+
var _dec$1, _dec2$1, _class$1;
|
|
67
|
+
const overrideMethod = overrideMethodImport;
|
|
68
|
+
let MiddlewareSystemOverrideMethod = (_dec$1 = MiddlewareSystem({
|
|
69
|
+
dependencies: 'a-core:notfound',
|
|
70
|
+
allowedMethods: ['POST']
|
|
71
|
+
}), _dec2$1 = BeanInfo({
|
|
72
|
+
module: "a-core"
|
|
73
|
+
}), _dec$1(_class$1 = _dec2$1(_class$1 = class MiddlewareSystemOverrideMethod extends BeanBase {
|
|
74
|
+
constructor(...args) {
|
|
75
|
+
super(...args);
|
|
76
|
+
this._overrideMethod = void 0;
|
|
77
|
+
}
|
|
78
|
+
async execute(options, next) {
|
|
79
|
+
if (!this._overrideMethod) {
|
|
80
|
+
this._overrideMethod = overrideMethod(options);
|
|
81
|
+
}
|
|
82
|
+
return this._overrideMethod(this.ctx, next);
|
|
83
|
+
}
|
|
84
|
+
}) || _class$1) || _class$1);
|
|
85
|
+
|
|
86
|
+
var _dec, _dec2, _class;
|
|
87
|
+
let ScopeModuleACore = (_dec = Scope(), _dec2 = BeanInfo({
|
|
88
|
+
module: "a-core"
|
|
89
|
+
}), _dec(_class = _dec2(_class = class ScopeModuleACore extends BeanScopeBase {}) || _class) || _class);
|
|
90
|
+
|
|
91
|
+
/** scope: end */
|
|
92
|
+
|
|
93
|
+
function Gate(options) {
|
|
94
|
+
return Aspect.middlewareGlobal('a-core:gate', options);
|
|
95
|
+
}
|
|
96
|
+
const Core = {
|
|
97
|
+
gate: Gate
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { Core, MetaStatic, MiddlewareGate, MiddlewareSystemNotfound, MiddlewareSystemOverrideMethod, ScopeModuleACore };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.20",
|
|
5
5
|
"title": "a-core",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {},
|
|
@@ -85,12 +85,12 @@
|
|
|
85
85
|
"ts-node": "^10.9.2",
|
|
86
86
|
"tslib": "^2.8.1",
|
|
87
87
|
"typescript": "^5.7.3",
|
|
88
|
-
"vona-mock": "^6.0.
|
|
88
|
+
"vona-mock": "^6.0.18",
|
|
89
89
|
"why-is-node-running": "^3.2.2"
|
|
90
90
|
},
|
|
91
91
|
"gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
|
|
92
92
|
"scripts": {
|
|
93
93
|
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
94
|
-
"tsc:publish": "npm run clean && tsc -p tsconfig.build.json"
|
|
94
|
+
"tsc:publish": "npm run clean && vona :bin:buildModule && tsc -p tsconfig.build.json"
|
|
95
95
|
}
|
|
96
96
|
}
|
package/dist/.metadata/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
/** meta static: end */
|
|
8
|
-
/** scope: begin */
|
|
9
|
-
import { BeanScopeBase } from 'vona';
|
|
10
|
-
import { Scope } from 'vona-module-a-bean';
|
|
11
|
-
import 'vona';
|
|
12
|
-
import 'vona';
|
|
13
|
-
import 'vona';
|
|
14
|
-
import 'vona';
|
|
15
|
-
export * from "../bean/meta.static.js";
|
|
16
|
-
/** middleware: begin */
|
|
17
|
-
export * from "../bean/middleware.gate.js";
|
|
18
|
-
/** middleware: end */
|
|
19
|
-
/** middlewareSystem: begin */
|
|
20
|
-
export * from "../bean/middlewareSystem.notfound.js";
|
|
21
|
-
export * from "../bean/middlewareSystem.overrideMethod.js";
|
|
22
|
-
let ScopeModuleACore = class ScopeModuleACore extends BeanScopeBase {
|
|
23
|
-
};
|
|
24
|
-
ScopeModuleACore = __decorate([
|
|
25
|
-
Scope()
|
|
26
|
-
], ScopeModuleACore);
|
|
27
|
-
export { ScopeModuleACore };
|
|
28
|
-
/** scope: end */
|
package/dist/.metadata/this.js
DELETED
package/dist/bean/meta.static.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Meta } from 'vona-module-a-meta';
|
|
8
|
-
import { BeanStaticBase } from 'vona-module-a-static';
|
|
9
|
-
let MetaStatic = class MetaStatic extends BeanStaticBase {
|
|
10
|
-
};
|
|
11
|
-
MetaStatic = __decorate([
|
|
12
|
-
Meta()
|
|
13
|
-
], MetaStatic);
|
|
14
|
-
export { MetaStatic };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { BeanBase } from 'vona';
|
|
8
|
-
import { Middleware } from 'vona-module-a-aspect';
|
|
9
|
-
let MiddlewareGate = class MiddlewareGate extends BeanBase {
|
|
10
|
-
async execute(options, next) {
|
|
11
|
-
// check gate
|
|
12
|
-
if (!this.app.bean.onion.checkOnionOptionsMeta(options.gate)) {
|
|
13
|
-
this.app.throw(403);
|
|
14
|
-
}
|
|
15
|
-
// next
|
|
16
|
-
return next();
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
MiddlewareGate = __decorate([
|
|
20
|
-
Middleware({ global: true })
|
|
21
|
-
], MiddlewareGate);
|
|
22
|
-
export { MiddlewareGate };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { BeanBase } from 'vona';
|
|
8
|
-
import { MiddlewareSystem } from 'vona-module-a-aspect';
|
|
9
|
-
let MiddlewareSystemNotfound = class MiddlewareSystemNotfound extends BeanBase {
|
|
10
|
-
async execute(options, next) {
|
|
11
|
-
const ctx = this.ctx;
|
|
12
|
-
await next();
|
|
13
|
-
if (ctx.status !== 404 || ctx.body) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
// set status first, make sure set body not set status
|
|
17
|
-
ctx.status = 404;
|
|
18
|
-
if (ctx.acceptJSON) {
|
|
19
|
-
ctx.body = {
|
|
20
|
-
message: 'Not Found',
|
|
21
|
-
};
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const notFoundHtml = '<h1>404 Not Found</h1>';
|
|
25
|
-
// notfound handler is unimplemented
|
|
26
|
-
if (options.pageUrl && ctx.path === options.pageUrl) {
|
|
27
|
-
ctx.body = `${notFoundHtml}<p><pre><code>config.notfound.pageUrl(${options.pageUrl})</code></pre> is unimplemented</p>`;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (options.pageUrl) {
|
|
31
|
-
ctx.realStatus = 404;
|
|
32
|
-
ctx.redirect(options.pageUrl);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
ctx.body = notFoundHtml;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
MiddlewareSystemNotfound = __decorate([
|
|
39
|
-
MiddlewareSystem({ dependencies: 'a-logger:httpLog' })
|
|
40
|
-
], MiddlewareSystemNotfound);
|
|
41
|
-
export { MiddlewareSystemNotfound };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import overrideMethodImport from 'koa-override';
|
|
8
|
-
import { BeanBase } from 'vona';
|
|
9
|
-
import { MiddlewareSystem } from 'vona-module-a-aspect';
|
|
10
|
-
const overrideMethod = overrideMethodImport;
|
|
11
|
-
let MiddlewareSystemOverrideMethod = class MiddlewareSystemOverrideMethod extends BeanBase {
|
|
12
|
-
_overrideMethod;
|
|
13
|
-
async execute(options, next) {
|
|
14
|
-
if (!this._overrideMethod) {
|
|
15
|
-
this._overrideMethod = overrideMethod(options);
|
|
16
|
-
}
|
|
17
|
-
return this._overrideMethod(this.ctx, next);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
MiddlewareSystemOverrideMethod = __decorate([
|
|
21
|
-
MiddlewareSystem({
|
|
22
|
-
dependencies: 'a-core:notfound',
|
|
23
|
-
allowedMethods: ['POST'],
|
|
24
|
-
})
|
|
25
|
-
], MiddlewareSystemOverrideMethod);
|
|
26
|
-
export { MiddlewareSystemOverrideMethod };
|
package/dist/lib/core.js
DELETED
package/dist/lib/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./core.js";
|