jcc-express-mvc 1.3.11 → 1.3.12
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/Dependency.d.ts +2 -0
- package/Dependency.d.ts.map +1 -0
- package/Dependency.js +17 -0
- package/lib/App.d.ts +2 -1
- package/lib/App.d.ts.map +1 -1
- package/lib/Dependancy/index.d.ts +4 -0
- package/lib/Dependancy/index.d.ts.map +1 -0
- package/lib/Dependancy/index.js +24 -0
- package/lib/Error/AppErrorHandler.d.ts.map +1 -1
- package/lib/Error/AppErrorHandler.js +6 -4
- package/lib/Error/DisplayErrorCode.js +1 -1
- package/lib/Error/public/error.html +20 -47
- package/lib/Routes/RouteBuilder.d.ts +1 -0
- package/lib/Routes/RouteBuilder.d.ts.map +1 -1
- package/lib/Routes/RouteBuilder.js +8 -42
- package/lib/Services/ServiceContainer.d.ts +2 -0
- package/lib/Services/ServiceContainer.d.ts.map +1 -1
- package/lib/Services/ServiceContainer.js +13 -0
- package/lib/Type/index.d.ts +1 -0
- package/lib/Type/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/Command-Line/ConsoleKernel.d.ts +0 -7
- package/lib/Command-Line/ConsoleKernel.d.ts.map +0 -1
- package/lib/Command-Line/ConsoleKernel.js +0 -14
package/Dependency.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dependency.d.ts","sourceRoot":"","sources":["../framework/Dependency.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/Dependency.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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("./lib/Dependancy"), exports);
|
package/lib/App.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Router } from "./Routes/Router";
|
|
2
2
|
import { HttpSever } from "./Server";
|
|
3
|
+
import { ServiceContainer } from "./Services/ServiceContainer";
|
|
3
4
|
declare class App extends HttpSever {
|
|
4
|
-
|
|
5
|
+
container: ServiceContainer;
|
|
5
6
|
constructor();
|
|
6
7
|
private initiateProviders;
|
|
7
8
|
webRoutes(): Router<any>;
|
package/lib/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../framework/lib/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../framework/lib/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,cAAM,GAAI,SAAQ,SAAS;IAGlB,SAAS,mBAA0B;;IAS1C,OAAO,CAAC,iBAAiB;IAQlB,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC;IAQ/B;;;OAGG;IACI,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC;IAQ/B;;;OAGG;IACI,UAAU,IAAI,GAAG;CAYzB;AAED,eAAO,MAAM,GAAG,KAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../framework/lib/Dependancy/index.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAG1B,wBAAgB,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAc/D;AAED,wBAAgB,UAAU,CAAC,SAAS,GAAE,OAAe,GAAG,cAAc,CAOrE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Inject = Inject;
|
|
4
|
+
exports.Injectable = Injectable;
|
|
5
|
+
const App_1 = require("../App");
|
|
6
|
+
require("reflect-metadata");
|
|
7
|
+
//
|
|
8
|
+
function Inject(serviceName) {
|
|
9
|
+
return (target, propertyKey, parameterIndex) => {
|
|
10
|
+
const existingInjectedParameters = Reflect.getMetadata("inject_params", target) || [];
|
|
11
|
+
// Add the new injection metadata (index ensures correct parameter order)
|
|
12
|
+
existingInjectedParameters[parameterIndex] = { serviceName };
|
|
13
|
+
// Define the metadata again, ensuring the parameters are in correct order
|
|
14
|
+
Reflect.defineMetadata("inject_params", existingInjectedParameters, target);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function Injectable(singleton = false) {
|
|
18
|
+
const container = App_1.app.container;
|
|
19
|
+
return function (target) {
|
|
20
|
+
singleton
|
|
21
|
+
? container.singleton(target.name, () => new target())
|
|
22
|
+
: container.bind(target.name, () => new target());
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppErrorHandler.d.ts","sourceRoot":"","sources":["../../../framework/lib/Error/AppErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMtC,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAc;gBACb,GAAG,EAAE,WAAW;IAI5B;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,kBAAkB;IAMzB,OAAO,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"AppErrorHandler.d.ts","sourceRoot":"","sources":["../../../framework/lib/Error/AppErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMtC,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAc;gBACb,GAAG,EAAE,WAAW;IAI5B;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,kBAAkB;IAMzB,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,GAAG,EAAE,GAAG;CAoCjB"}
|
|
@@ -24,8 +24,7 @@ class AppErrorHandler {
|
|
|
24
24
|
return res.sendFile(__dirname + "/public/pageNotFound.html");
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
extractErrorPath(stackArray, isDatabaseError = false) {
|
|
28
|
-
let index = 1;
|
|
27
|
+
extractErrorPath(stackArray, isDatabaseError = false, index = 1) {
|
|
29
28
|
if (!isDatabaseError) {
|
|
30
29
|
const lastError = stackArray[stackArray.length - 1];
|
|
31
30
|
const parts = lastError.split(/\s/g);
|
|
@@ -34,9 +33,12 @@ class AppErrorHandler {
|
|
|
34
33
|
const currentError = stackArray[index];
|
|
35
34
|
const parts = currentError.split(/\s/g);
|
|
36
35
|
const errorPath = parts[parts.length - 1];
|
|
36
|
+
console.log(errorPath);
|
|
37
|
+
if (index >= 5) {
|
|
38
|
+
return "Internal server error";
|
|
39
|
+
}
|
|
37
40
|
if (!this.isPath(errorPath)) {
|
|
38
|
-
index
|
|
39
|
-
return this.extractErrorPath(stackArray, true);
|
|
41
|
+
return this.extractErrorPath(stackArray, true, index + 1);
|
|
40
42
|
}
|
|
41
43
|
return errorPath;
|
|
42
44
|
}
|
|
@@ -26,7 +26,7 @@ class DisplayError extends ErrorHightLight_1.ErrorHighLighter {
|
|
|
26
26
|
let formattedContent = content
|
|
27
27
|
.map((line, index) => `${index + 1}. ${line}`)
|
|
28
28
|
.join("\n");
|
|
29
|
-
return this.renderHtml(res, formattedContent, startLine, `${message.trim()}
|
|
29
|
+
return this.renderHtml(res, formattedContent, startLine, `${message.trim()} <p> ${pathParts.join("/").trim()} ${startLine}:${endLine} </p>`);
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
32
|
return res.status(500).json({ message: "Internal Error" });
|
|
@@ -14,58 +14,31 @@
|
|
|
14
14
|
<body class="">
|
|
15
15
|
<div class="code-container">
|
|
16
16
|
<div class="error-message">
|
|
17
|
-
|
|
18
|
-
/media/abdou/Partition/GAMBTECH/PROGRAMMING/TYPESCRIPT/jcc/app/Http/Controllers/UsersController.ts 26:18
|
|
17
|
+
Expected property name or '}' in JSON at position 1 (line 1 column 2) <p> /media/abdou/Partition/GAMBTECH/PROGRAMMING/TYPESCRIPT/jcc/app/Services/CategorySercvice.ts 16:17 </p>
|
|
19
18
|
</div>
|
|
20
19
|
<div class="container">
|
|
21
20
|
<pre
|
|
22
|
-
data-line="
|
|
21
|
+
data-line="16"
|
|
23
22
|
class="line-numbers"
|
|
24
|
-
><code class="language-javascript">1. import {
|
|
25
|
-
2. import {
|
|
26
|
-
3.
|
|
27
|
-
4.
|
|
28
|
-
5. export class
|
|
29
|
-
6.
|
|
30
|
-
7.
|
|
31
|
-
8.
|
|
23
|
+
><code class="language-javascript">1. import { Category } from "../Models/Category";
|
|
24
|
+
2. import { Injectable } from "../../framework/Providers";
|
|
25
|
+
3.
|
|
26
|
+
4. @Injectable()
|
|
27
|
+
5. export class CategoryService {
|
|
28
|
+
6. async all() {
|
|
29
|
+
7. return Category.with("products").take(5).get();
|
|
30
|
+
8. }
|
|
32
31
|
9.
|
|
33
|
-
10. async
|
|
34
|
-
11.
|
|
35
|
-
12.
|
|
36
|
-
13.
|
|
37
|
-
14.
|
|
38
|
-
15.
|
|
39
|
-
16.
|
|
40
|
-
17.
|
|
41
|
-
18.
|
|
42
|
-
19.
|
|
43
|
-
20. await req.validate({
|
|
44
|
-
21. name: ["required"],
|
|
45
|
-
22. email: ["required", "unique:users"],
|
|
46
|
-
23. password: ["required", "min:6"],
|
|
47
|
-
24. });
|
|
48
|
-
25.
|
|
49
|
-
26. const save = await User.create({
|
|
50
|
-
27. name: req.body.name,
|
|
51
|
-
28. email: req.body.email,
|
|
52
|
-
29. password: await bcrypt(req.body.password),
|
|
53
|
-
30. });
|
|
54
|
-
31.
|
|
55
|
-
32. return save
|
|
56
|
-
33. ? Auth.attempt(req, res, next)
|
|
57
|
-
34. : res.json({ message: "Invalid credentials" });
|
|
58
|
-
35. }
|
|
59
|
-
36.
|
|
60
|
-
37. //
|
|
61
|
-
38.
|
|
62
|
-
39. async show(req: Request, res: Response, next: Next) {
|
|
63
|
-
40. return res.json({
|
|
64
|
-
41. message: await User.find(req.params.id),
|
|
65
|
-
42. });
|
|
66
|
-
43. }
|
|
67
|
-
44. }
|
|
68
|
-
45. </code></pre>
|
|
32
|
+
10. async find(id: string | number) {
|
|
33
|
+
11. return Category.find(id);
|
|
34
|
+
12. }
|
|
35
|
+
13.
|
|
36
|
+
14. async test(a: any) {
|
|
37
|
+
15. console.log(1);
|
|
38
|
+
16. return JSON.parse(`{a}`);
|
|
39
|
+
17. }
|
|
40
|
+
18. }
|
|
41
|
+
19. </code></pre>
|
|
69
42
|
</div>
|
|
70
43
|
</div>
|
|
71
44
|
<script src="/js/app-error-prism.js"> </script>
|
|
@@ -43,6 +43,7 @@ export declare class RouteBuilder {
|
|
|
43
43
|
*/
|
|
44
44
|
private createRoute;
|
|
45
45
|
buildRoute<T>(httpMethod: keyof Application, url: string, callback: RequestHandler | string | Array<any>): any;
|
|
46
|
+
resolveController<T>(controller: new (...args: any[]) => T): T;
|
|
46
47
|
private resolveHandler;
|
|
47
48
|
}
|
|
48
49
|
//# sourceMappingURL=RouteBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteBuilder.d.ts","sourceRoot":"","sources":["../../../framework/lib/Routes/RouteBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAM;IAE/B,OAAO,CAAC,MAAM,CAAC,UAAU,CAA+B;gBAEtD,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,OAAO;IAUlB;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAM3C;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAK9B;;;OAGG;WACW,SAAS,CAAC,UAAU,GAAE,KAAK,CAAC,GAAG,CAAC,GAAG,eAAoB;IAIrE;;;OAGG;WACW,aAAa,CAAC,UAAU,EAAE,GAAG;IAI3C,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,cAAc;
|
|
1
|
+
{"version":3,"file":"RouteBuilder.d.ts","sourceRoot":"","sources":["../../../framework/lib/Routes/RouteBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAM;IAE/B,OAAO,CAAC,MAAM,CAAC,UAAU,CAA+B;gBAEtD,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,OAAO;IAUlB;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAM3C;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAK9B;;;OAGG;WACW,SAAS,CAAC,UAAU,GAAE,KAAK,CAAC,GAAG,CAAC,GAAG,eAAoB;IAIrE;;;OAGG;WACW,aAAa,CAAC,UAAU,EAAE,GAAG;IAI3C,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,cAAc;IAevE,aAAa,IAAI,OAAO;IAMxB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAaZ,UAAU,CAAC,CAAC,EACjB,UAAU,EAAE,MAAM,WAAW,EAC7B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,cAAc,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;IAazC,iBAAiB,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;IAIrE,OAAO,CAAC,cAAc;CAyBvB"}
|
|
@@ -51,7 +51,7 @@ class RouteBuilder {
|
|
|
51
51
|
if (Array.isArray(callback)) {
|
|
52
52
|
if (callback.length == 2) {
|
|
53
53
|
const [Controller, method] = callback;
|
|
54
|
-
const instance = new Controller(
|
|
54
|
+
const instance = new Controller();
|
|
55
55
|
return instance[method];
|
|
56
56
|
}
|
|
57
57
|
throw new AppError_1.AppError(`Method not define ${callback[0]}`, error_1.ROUTE_CALLBACK_ERROR);
|
|
@@ -67,46 +67,6 @@ class RouteBuilder {
|
|
|
67
67
|
* @param {string} url - The route path.
|
|
68
68
|
* @param {string} callback - The callback function or method name.
|
|
69
69
|
*/
|
|
70
|
-
// public buildRoute<T>(
|
|
71
|
-
// httpMethod: keyof Application,
|
|
72
|
-
// url: string,
|
|
73
|
-
// callback: RequestHandler | string,
|
|
74
|
-
// ) {
|
|
75
|
-
// try {
|
|
76
|
-
// const middleware = RouteBuilder.middleware || [];
|
|
77
|
-
// RouteBuilder.middleware = [];
|
|
78
|
-
// if (this.hasController() && typeof callback === "string") {
|
|
79
|
-
// const Controller = RouteBuilder.controller;
|
|
80
|
-
// const instance = new Controller(
|
|
81
|
-
// this.serviceContainer?.resolve(Controller.name),
|
|
82
|
-
// );
|
|
83
|
-
// return middleware.length > 0
|
|
84
|
-
// ? this.app[httpMethod](
|
|
85
|
-
// this.resolvePath(url),
|
|
86
|
-
// middleware,
|
|
87
|
-
// asyncHandler(instance[callback].bind(instance)),
|
|
88
|
-
// )
|
|
89
|
-
// : this.app[httpMethod](
|
|
90
|
-
// this.resolvePath(url),
|
|
91
|
-
// asyncHandler(instance[callback].bind(instance)),
|
|
92
|
-
// );
|
|
93
|
-
// }
|
|
94
|
-
// if (typeof callback === "function" || Array.isArray(callback)) {
|
|
95
|
-
// return middleware.length > 0
|
|
96
|
-
// ? this.app[httpMethod](
|
|
97
|
-
// this.resolvePath(url),
|
|
98
|
-
// middleware,
|
|
99
|
-
// asyncHandler(this.validateCallback(callback)),
|
|
100
|
-
// )
|
|
101
|
-
// : this.app[httpMethod](
|
|
102
|
-
// this.resolvePath(url),
|
|
103
|
-
// asyncHandler(this.validateCallback(callback)),
|
|
104
|
-
// );
|
|
105
|
-
// }
|
|
106
|
-
// } catch (error: any) {
|
|
107
|
-
// throw new AppError(error.message, ROUTE_BUILDER_ERROR);
|
|
108
|
-
// }
|
|
109
|
-
// }
|
|
110
70
|
createRoute(httpMethod, url, middleware, handler) {
|
|
111
71
|
return this.app[httpMethod](this.resolvePath(url), middleware, (0, util_1.asyncHandler)(handler));
|
|
112
72
|
}
|
|
@@ -121,10 +81,16 @@ class RouteBuilder {
|
|
|
121
81
|
throw new AppError_1.AppError(error.message, error_1.ROUTE_BUILDER_ERROR);
|
|
122
82
|
}
|
|
123
83
|
}
|
|
84
|
+
resolveController(controller) {
|
|
85
|
+
return this.serviceContainer.resolveDynamicInjection(controller);
|
|
86
|
+
}
|
|
124
87
|
resolveHandler(callback) {
|
|
125
88
|
if (this.hasController() && typeof callback === "string") {
|
|
126
89
|
const Controller = RouteBuilder.controller;
|
|
127
|
-
|
|
90
|
+
this.serviceContainer.bind(Controller.name, () => new Controller());
|
|
91
|
+
const instance = this.resolveController(Controller);
|
|
92
|
+
// console.log(instance);
|
|
93
|
+
//new Controller();
|
|
128
94
|
// Ensure the method exists on the instance
|
|
129
95
|
if (typeof instance[callback] !== "function") {
|
|
130
96
|
throw new AppError_1.AppError(`Method ${callback} not found on controller`, error_1.ROUTE_CALLBACK_ERROR);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
1
2
|
export declare class ServiceContainer {
|
|
2
3
|
private bindings;
|
|
3
4
|
private instances;
|
|
@@ -7,5 +8,6 @@ export declare class ServiceContainer {
|
|
|
7
8
|
call<T>(method: string, ...args: any[]): T;
|
|
8
9
|
make<T>(key: string): T | undefined;
|
|
9
10
|
alias(key: string, alias: string): void;
|
|
11
|
+
resolveDynamicInjection<T>(target: new (...args: any[]) => T): T;
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=ServiceContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceContainer.d.ts","sourceRoot":"","sources":["../../../framework/lib/Services/ServiceContainer.ts"],"names":[],"mappings":"AAA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,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAOvC,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;CAcxE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ServiceContainer = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
4
5
|
class ServiceContainer {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.bindings = new Map();
|
|
@@ -45,5 +46,17 @@ class ServiceContainer {
|
|
|
45
46
|
}
|
|
46
47
|
this.bindings.set(alias, this.bindings.get(key));
|
|
47
48
|
}
|
|
49
|
+
resolveDynamicInjection(target) {
|
|
50
|
+
const injectParams = Reflect.getMetadata("inject_params", target) || [];
|
|
51
|
+
const args = injectParams.map((param) => {
|
|
52
|
+
const service = this.resolve(param.serviceName);
|
|
53
|
+
if (!service) {
|
|
54
|
+
throw new Error(`Service ${param.serviceName} not found`);
|
|
55
|
+
}
|
|
56
|
+
return service;
|
|
57
|
+
});
|
|
58
|
+
// Instantiate the class with the resolved dependencies
|
|
59
|
+
return new target(...args);
|
|
60
|
+
}
|
|
48
61
|
}
|
|
49
62
|
exports.ServiceContainer = ServiceContainer;
|
package/lib/Type/index.d.ts
CHANGED
package/lib/Type/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../framework/lib/Type/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kB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EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleKernel.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/ConsoleKernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,qBAAa,aAAa;IACZ,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,OAAO;IAItC,OAAO,CAAC,IAAI,EAAE,GAAG;CAIlB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConsoleKernel = void 0;
|
|
4
|
-
class ConsoleKernel {
|
|
5
|
-
constructor(commander) {
|
|
6
|
-
this.commander = commander;
|
|
7
|
-
console.log(commander);
|
|
8
|
-
}
|
|
9
|
-
getArgv(argv) {
|
|
10
|
-
// this.commander.
|
|
11
|
-
console.log(argv);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.ConsoleKernel = ConsoleKernel;
|