vona-module-a-core 5.0.14 → 5.0.16
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/.metadata/index.d.ts +68 -0
- package/dist/.metadata/index.js +28 -0
- package/dist/.metadata/this.d.ts +2 -0
- package/dist/.metadata/this.js +2 -0
- package/dist/bean/meta.static.d.ts +7 -0
- package/dist/bean/meta.static.js +14 -0
- package/dist/bean/middleware.gate.d.ts +10 -0
- package/dist/bean/middleware.gate.js +22 -0
- package/dist/bean/middlewareSystem.notfound.d.ts +9 -0
- package/dist/bean/middlewareSystem.notfound.js +41 -0
- package/dist/bean/middlewareSystem.overrideMethod.d.ts +10 -0
- package/dist/bean/middlewareSystem.overrideMethod.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/core.d.ts +7 -0
- package/dist/lib/core.js +7 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/package.json +20 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { BeanScopeUtil } from 'vona';
|
|
2
|
+
/** meta: end */
|
|
3
|
+
/** meta static: begin */
|
|
4
|
+
import type { MetaStatic } from '../bean/meta.static.ts';
|
|
5
|
+
/** middlewareSystem: end */
|
|
6
|
+
/** meta: begin */
|
|
7
|
+
import type { IMiddlewareOptionsGate } from '../bean/middleware.gate.ts';
|
|
8
|
+
import type { IMiddlewareSystemOptionsNotfound } from '../bean/middlewareSystem.notfound.ts';
|
|
9
|
+
import type { IMiddlewareSystemOptionsOverrideMethod } from '../bean/middlewareSystem.overrideMethod.ts';
|
|
10
|
+
/** meta static: end */
|
|
11
|
+
/** scope: begin */
|
|
12
|
+
import { BeanScopeBase } from 'vona';
|
|
13
|
+
import 'vona';
|
|
14
|
+
import 'vona';
|
|
15
|
+
import 'vona';
|
|
16
|
+
import 'vona';
|
|
17
|
+
export * from '../bean/meta.static.ts';
|
|
18
|
+
declare module 'vona-module-a-aspect' {
|
|
19
|
+
interface IMiddlewareRecordGlobal {
|
|
20
|
+
'a-core:gate': IMiddlewareOptionsGate;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
declare module 'vona-module-a-core' {
|
|
24
|
+
interface MiddlewareGate {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** middleware: begin */
|
|
28
|
+
export * from '../bean/middleware.gate.ts';
|
|
29
|
+
/** middleware: end */
|
|
30
|
+
/** middlewareSystem: begin */
|
|
31
|
+
export * from '../bean/middlewareSystem.notfound.ts';
|
|
32
|
+
declare module 'vona-module-a-aspect' {
|
|
33
|
+
interface IMiddlewareSystemRecord {
|
|
34
|
+
'a-core:notfound': IMiddlewareSystemOptionsNotfound;
|
|
35
|
+
'a-core:overrideMethod': IMiddlewareSystemOptionsOverrideMethod;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
declare module 'vona-module-a-core' {
|
|
39
|
+
interface MiddlewareSystemNotfound {
|
|
40
|
+
}
|
|
41
|
+
interface MiddlewareSystemOverrideMethod {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export * from '../bean/middlewareSystem.overrideMethod.ts';
|
|
45
|
+
declare module 'vona' {
|
|
46
|
+
interface IMetaRecord {
|
|
47
|
+
'a-core:static': never;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
declare module 'vona-module-a-core' {
|
|
51
|
+
interface MetaStatic {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export declare class ScopeModuleACore extends BeanScopeBase {
|
|
55
|
+
}
|
|
56
|
+
export interface ScopeModuleACore {
|
|
57
|
+
util: BeanScopeUtil;
|
|
58
|
+
static: MetaStatic;
|
|
59
|
+
}
|
|
60
|
+
declare module 'vona' {
|
|
61
|
+
interface IBeanScopeRecord {
|
|
62
|
+
'a-core': ScopeModuleACore;
|
|
63
|
+
}
|
|
64
|
+
interface IBeanScopeContainer {
|
|
65
|
+
core: ScopeModuleACore;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** scope: end */
|
|
@@ -0,0 +1,28 @@
|
|
|
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 */
|
|
@@ -0,0 +1,14 @@
|
|
|
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 };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Next } from 'vona';
|
|
2
|
+
import type { IDecoratorMiddlewareOptionsGlobal, IMiddlewareExecute } from 'vona-module-a-aspect';
|
|
3
|
+
import type { IOnionOptionsMeta } from 'vona-module-a-onion';
|
|
4
|
+
import { BeanBase } from 'vona';
|
|
5
|
+
export interface IMiddlewareOptionsGate extends IDecoratorMiddlewareOptionsGlobal {
|
|
6
|
+
gate?: IOnionOptionsMeta;
|
|
7
|
+
}
|
|
8
|
+
export declare class MiddlewareGate extends BeanBase implements IMiddlewareExecute {
|
|
9
|
+
execute(options: IMiddlewareOptionsGate, next: Next): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Next } from 'vona';
|
|
2
|
+
import type { IDecoratorMiddlewareSystemOptions, IMiddlewareSystemExecute } from 'vona-module-a-aspect';
|
|
3
|
+
import { BeanBase } from 'vona';
|
|
4
|
+
export interface IMiddlewareSystemOptionsNotfound extends IDecoratorMiddlewareSystemOptions {
|
|
5
|
+
pageUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class MiddlewareSystemNotfound extends BeanBase implements IMiddlewareSystemExecute {
|
|
8
|
+
execute(options: IMiddlewareSystemOptionsNotfound, next: Next): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Next } from 'vona';
|
|
2
|
+
import type { IDecoratorMiddlewareSystemOptions, IMiddlewareSystemExecute } from 'vona-module-a-aspect';
|
|
3
|
+
import { BeanBase } from 'vona';
|
|
4
|
+
export interface IMiddlewareSystemOptionsOverrideMethod extends IDecoratorMiddlewareSystemOptions {
|
|
5
|
+
allowedMethods?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class MiddlewareSystemOverrideMethod extends BeanBase implements IMiddlewareSystemExecute {
|
|
8
|
+
private _overrideMethod;
|
|
9
|
+
execute(options: IMiddlewareSystemOptionsOverrideMethod, next: Next): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TypeUseOnionOmitOptionsGlobal } from 'vona-module-a-onion';
|
|
2
|
+
import type { IMiddlewareOptionsGate } from '../bean/middleware.gate.ts';
|
|
3
|
+
declare function Gate(options?: Partial<TypeUseOnionOmitOptionsGlobal<IMiddlewareOptionsGate>>): ClassDecorator & MethodDecorator;
|
|
4
|
+
export declare const Core: {
|
|
5
|
+
gate: typeof Gate;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
package/dist/lib/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './core.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core.js";
|
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.16",
|
|
5
5
|
"title": "a-core",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {},
|
|
@@ -75,9 +75,26 @@
|
|
|
75
75
|
"vona-shared": "^1.0.17",
|
|
76
76
|
"winston": "^3.17.0"
|
|
77
77
|
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@cabloy/cli": "^3.0.24",
|
|
80
|
+
"@cabloy/lint": "^5.0.16",
|
|
81
|
+
"@swc/core": "^1.7.36",
|
|
82
|
+
"@swc/helpers": "^0.5.13",
|
|
83
|
+
"@types/node": "^22.10.2",
|
|
84
|
+
"@types/retry": "^0.12.5",
|
|
85
|
+
"clean-package": "^2.2.0",
|
|
86
|
+
"cross-env": "^7.0.3",
|
|
87
|
+
"eslint": "^9.20.1",
|
|
88
|
+
"rimraf": "^6.0.1",
|
|
89
|
+
"ts-node": "^10.9.2",
|
|
90
|
+
"tslib": "^2.8.1",
|
|
91
|
+
"typescript": "^5.7.3",
|
|
92
|
+
"vona-mock": "^6.0.17",
|
|
93
|
+
"why-is-node-running": "^3.2.2"
|
|
94
|
+
},
|
|
78
95
|
"gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
|
|
79
96
|
"scripts": {
|
|
80
|
-
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
81
|
-
"tsc:publish": "npm run clean && tsc"
|
|
97
|
+
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
98
|
+
"tsc:publish": "npm run clean && tsc -p tsconfig.build.json"
|
|
82
99
|
}
|
|
83
100
|
}
|