@zenofolio/hyper-decor 0.0.3
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/.mocharc.js +5 -0
- package/LICENSE +21 -0
- package/README.md +191 -0
- package/dist/__internals/constants.d.ts +61 -0
- package/dist/__internals/constants.js +72 -0
- package/dist/__internals/creators/request.creator.d.ts +12 -0
- package/dist/__internals/creators/request.creator.js +53 -0
- package/dist/__internals/creators/routes.creator.d.ts +10 -0
- package/dist/__internals/creators/routes.creator.js +37 -0
- package/dist/__internals/decorator-base.d.ts +30 -0
- package/dist/__internals/decorator-base.js +86 -0
- package/dist/__internals/helpers/merge-metadata.d.ts +14 -0
- package/dist/__internals/helpers/merge-metadata.js +44 -0
- package/dist/__internals/helpers/who.helper.d.ts +9 -0
- package/dist/__internals/helpers/who.helper.js +19 -0
- package/dist/__internals/store.d.ts +10 -0
- package/dist/__internals/store.js +17 -0
- package/dist/__internals/stores/index.d.ts +15 -0
- package/dist/__internals/stores/index.js +37 -0
- package/dist/__internals/stores/middleware.store.d.ts +7 -0
- package/dist/__internals/stores/middleware.store.js +19 -0
- package/dist/__internals/stores/params.store.d.ts +21 -0
- package/dist/__internals/stores/params.store.js +65 -0
- package/dist/__internals/stores/routes.store.d.ts +17 -0
- package/dist/__internals/stores/routes.store.js +43 -0
- package/dist/__internals/stores/store.interface.d.ts +8 -0
- package/dist/__internals/stores/store.interface.js +2 -0
- package/dist/__internals/transform/method.transform.d.ts +2 -0
- package/dist/__internals/transform/method.transform.js +20 -0
- package/dist/__internals/transform/pass.transfrom.d.ts +1 -0
- package/dist/__internals/transform/pass.transfrom.js +2 -0
- package/dist/__internals/transform/role.transform.d.ts +7 -0
- package/dist/__internals/transform/role.transform.js +86 -0
- package/dist/__internals/transform/scope.transfrom.d.ts +7 -0
- package/dist/__internals/transform/scope.transfrom.js +72 -0
- package/dist/__internals/types.d.ts +8 -0
- package/dist/__internals/types.js +2 -0
- package/dist/__internals/utils/function.util.d.ts +4 -0
- package/dist/__internals/utils/function.util.js +20 -0
- package/dist/__internals/utils/mixin.utils.d.ts +11 -0
- package/dist/__internals/utils/mixin.utils.js +34 -0
- package/dist/__internals/utils/object.util.d.ts +27 -0
- package/dist/__internals/utils/object.util.js +72 -0
- package/dist/__internals/utils/path.util.d.ts +4 -0
- package/dist/__internals/utils/path.util.js +8 -0
- package/dist/__internals/utils/router.d.ts +1 -0
- package/dist/__internals/utils/router.js +2 -0
- package/dist/common/bootstrap.d.ts +3 -0
- package/dist/common/bootstrap.js +25 -0
- package/dist/common/helpers/index.d.ts +2 -0
- package/dist/common/helpers/index.js +18 -0
- package/dist/common/helpers/role.d.ts +22 -0
- package/dist/common/helpers/role.js +43 -0
- package/dist/common/helpers/scopes.d.ts +23 -0
- package/dist/common/helpers/scopes.js +47 -0
- package/dist/common/openapi/collect-class-data.d.ts +21 -0
- package/dist/common/openapi/collect-class-data.js +45 -0
- package/dist/common/openapi/collect-function-data.d.ts +32 -0
- package/dist/common/openapi/collect-function-data.js +70 -0
- package/dist/common/openapi/index.d.ts +2 -0
- package/dist/common/openapi/index.js +18 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +6 -0
- package/dist/decorators/File.d.ts +65 -0
- package/dist/decorators/File.js +180 -0
- package/dist/decorators/Http.d.ts +55 -0
- package/dist/decorators/Http.js +93 -0
- package/dist/decorators/HyperApp.d.ts +7 -0
- package/dist/decorators/HyperApp.js +262 -0
- package/dist/decorators/HyperController.d.ts +2 -0
- package/dist/decorators/HyperController.js +19 -0
- package/dist/decorators/HyperModule.d.ts +5 -0
- package/dist/decorators/HyperModule.js +14 -0
- package/dist/decorators/Middleware.d.ts +24 -0
- package/dist/decorators/Middleware.js +51 -0
- package/dist/decorators/Pass.d.ts +12 -0
- package/dist/decorators/Pass.js +29 -0
- package/dist/decorators/Role.d.ts +6 -0
- package/dist/decorators/Role.js +34 -0
- package/dist/decorators/Routes.d.ts +14 -0
- package/dist/decorators/Routes.js +21 -0
- package/dist/decorators/Scope.d.ts +6 -0
- package/dist/decorators/Scope.js +25 -0
- package/dist/decorators/index.d.ts +11 -0
- package/dist/decorators/index.js +27 -0
- package/dist/decorators/types.d.ts +89 -0
- package/dist/decorators/types.js +2 -0
- package/dist/exeptions/DuplicateControllerPathException.d.ts +14 -0
- package/dist/exeptions/DuplicateControllerPathException.js +12 -0
- package/dist/exeptions/DuplicatedException.d.ts +8 -0
- package/dist/exeptions/DuplicatedException.js +12 -0
- package/dist/exeptions/DuplicatedHandlerException.d.ts +4 -0
- package/dist/exeptions/DuplicatedHandlerException.js +12 -0
- package/dist/exeptions/HyperException.d.ts +7 -0
- package/dist/exeptions/HyperException.js +13 -0
- package/dist/exeptions/HyperFileException.d.ts +4 -0
- package/dist/exeptions/HyperFileException.js +12 -0
- package/dist/exeptions/MethodNotFountException.d.ts +4 -0
- package/dist/exeptions/MethodNotFountException.js +12 -0
- package/dist/exeptions/NotPropertyException.d.ts +6 -0
- package/dist/exeptions/NotPropertyException.js +16 -0
- package/dist/exeptions/NotRoleException.d.ts +6 -0
- package/dist/exeptions/NotRoleException.js +17 -0
- package/dist/exeptions/NotScopeException.d.ts +7 -0
- package/dist/exeptions/NotScopeException.js +18 -0
- package/dist/exeptions/WrongPlaceException.d.ts +8 -0
- package/dist/exeptions/WrongPlaceException.js +21 -0
- package/dist/exeptions/index.d.ts +8 -0
- package/dist/exeptions/index.js +18 -0
- package/dist/exeptions/types.d.ts +1 -0
- package/dist/exeptions/types.js +2 -0
- package/dist/extension.d.ts +1 -0
- package/dist/extension.js +41 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +25 -0
- package/dist/type.d.ts +10 -0
- package/dist/type.js +2 -0
- package/hyper-express-decorators.d.ts +16 -0
- package/package.json +61 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const hyper_express_1 = require("hyper-express");
|
|
4
|
+
const helpers_1 = require("./common/helpers");
|
|
5
|
+
/////////////////////////////
|
|
6
|
+
/// Mapa de métodos
|
|
7
|
+
/////////////////////////////
|
|
8
|
+
const requestMethods = {
|
|
9
|
+
setRole(role) {
|
|
10
|
+
(0, helpers_1.setRole)(this, role);
|
|
11
|
+
},
|
|
12
|
+
hasRole(role) {
|
|
13
|
+
return (0, helpers_1.hasRole)(this, role);
|
|
14
|
+
},
|
|
15
|
+
getRoles() {
|
|
16
|
+
return (0, helpers_1.getRoles)(this);
|
|
17
|
+
},
|
|
18
|
+
setScopes(scopes) {
|
|
19
|
+
(0, helpers_1.setScopes)(this, scopes);
|
|
20
|
+
},
|
|
21
|
+
hasScopes(scopes) {
|
|
22
|
+
return (0, helpers_1.hasScopes)(this, scopes);
|
|
23
|
+
},
|
|
24
|
+
getScopes() {
|
|
25
|
+
return (0, helpers_1.getScopes)(this);
|
|
26
|
+
},
|
|
27
|
+
setRoleScopes(role, scopes) {
|
|
28
|
+
this.setRole(role);
|
|
29
|
+
this.setScopes(scopes);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
/////////////////////////////
|
|
33
|
+
/// Agregar métodos al prototipo
|
|
34
|
+
/////////////////////////////
|
|
35
|
+
Object.entries(requestMethods).forEach(([key, method]) => {
|
|
36
|
+
Object.defineProperty(hyper_express_1.Request.prototype, key, {
|
|
37
|
+
value: method,
|
|
38
|
+
writable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
});
|
|
41
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./exeptions";
|
|
2
|
+
export * from "./constants";
|
|
3
|
+
export * from "./extension";
|
|
4
|
+
export * from "./decorators";
|
|
5
|
+
export * from "./common/helpers";
|
|
6
|
+
export * from "./common/bootstrap";
|
|
7
|
+
export * from "hyper-express";
|
|
8
|
+
export * from "tsyringe";
|
|
9
|
+
export * from "./type";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./exeptions"), exports);
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
|
19
|
+
__exportStar(require("./extension"), exports);
|
|
20
|
+
__exportStar(require("./decorators"), exports);
|
|
21
|
+
__exportStar(require("./common/helpers"), exports);
|
|
22
|
+
__exportStar(require("./common/bootstrap"), exports);
|
|
23
|
+
__exportStar(require("hyper-express"), exports);
|
|
24
|
+
__exportStar(require("tsyringe"), exports);
|
|
25
|
+
__exportStar(require("./type"), exports);
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Server } from "hyper-express";
|
|
2
|
+
export type HyperRoleOptions = string | string[];
|
|
3
|
+
export type HyperScopeOptions = string | string[];
|
|
4
|
+
export interface IHyperApplication extends Partial<Server> {
|
|
5
|
+
onPrepare(): void;
|
|
6
|
+
}
|
|
7
|
+
export type IHyperApp<T> = T & Server;
|
|
8
|
+
export interface IHyperAppTarget {
|
|
9
|
+
new (...args: any[]): IHyperApplication;
|
|
10
|
+
}
|
package/dist/type.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HyperRoleOptions, HyperScopeOptions } from "./src/type";
|
|
2
|
+
|
|
3
|
+
declare module "hyper-express" {
|
|
4
|
+
interface Request {
|
|
5
|
+
setRoleScopes(role: HyperRoleOptions, scopes: HyperScopeOptions): void;
|
|
6
|
+
|
|
7
|
+
getScopes(): string[] | undefined;
|
|
8
|
+
setScopes(scopes: HyperScopeOptions): void;
|
|
9
|
+
|
|
10
|
+
getRoles(): string[] | undefined;
|
|
11
|
+
setRole(role: HyperRoleOptions): void;
|
|
12
|
+
|
|
13
|
+
hasRole(role: HyperRoleOptions): boolean;
|
|
14
|
+
hasScopes(scopes: HyperScopeOptions): boolean;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenofolio/hyper-decor",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Project core with utilities and features",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"author": "zenozaga",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "mocha",
|
|
10
|
+
"test:server": "ts-node -r tsconfig-paths/register tests/server.bench.ts",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"publish": "npm run build && npm publish --access public"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"hyper-express": "^6.17.3"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/file-type": "^10.9.3",
|
|
19
|
+
"@types/mocha": "^10.0.8",
|
|
20
|
+
"chai": "^5.1.2",
|
|
21
|
+
"mocha": "^10.7.3",
|
|
22
|
+
"nodemon": "3.1.7",
|
|
23
|
+
"ts-node": "^10.9.2",
|
|
24
|
+
"typescript": "5.6.2"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@zenofolio/hyper-decor": "file:",
|
|
28
|
+
"core-decorators": "^0.20.0",
|
|
29
|
+
"file-type": "^19.5.0",
|
|
30
|
+
"hyper-express-decorators": "file:",
|
|
31
|
+
"reflect-metadata": "^0.2.2",
|
|
32
|
+
"tsyringe": "^4.8.0"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"default": "./dist/index.js",
|
|
37
|
+
"node": "./dist/index.js",
|
|
38
|
+
"import": "./src/index.ts"
|
|
39
|
+
},
|
|
40
|
+
"./decorators/*": {
|
|
41
|
+
"node": "./dist/decorators/*.js",
|
|
42
|
+
"default": "./src/decorators/*.ts"
|
|
43
|
+
},
|
|
44
|
+
"./helpers/*": {
|
|
45
|
+
"node": "./dist/common/helpers/*.js",
|
|
46
|
+
"default": "./src/common/helpers/*.ts"
|
|
47
|
+
},
|
|
48
|
+
"./exceptions/*": {
|
|
49
|
+
"node": "./dist/common/exceptions/*.js",
|
|
50
|
+
"default": "./src/common/exceptions/*.ts"
|
|
51
|
+
},
|
|
52
|
+
"./extension": {
|
|
53
|
+
"node": "./dist/extension.js",
|
|
54
|
+
"default": "./src/extension.ts"
|
|
55
|
+
},
|
|
56
|
+
"./injector": {
|
|
57
|
+
"node": "./dist/injector.js",
|
|
58
|
+
"default": "./src/injector.ts"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "Node16",
|
|
4
|
+
"moduleResolution": "Node16",
|
|
5
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
6
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
7
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
8
|
+
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
9
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
10
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
11
|
+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
|
12
|
+
|
|
13
|
+
"experimentalDecorators": true,
|
|
14
|
+
"emitDecoratorMetadata": true,
|
|
15
|
+
},
|
|
16
|
+
"exclude": ["node_modules", "dist", "tests", "examples"],
|
|
17
|
+
}
|