jcc-express-mvc 1.4.6 → 1.4.8
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/core/Container.d.ts.map +1 -0
- package/core/Dependency.d.ts +2 -0
- package/core/Dependency.d.ts.map +1 -0
- package/{Dependency.js → core/Dependency.js} +1 -1
- package/core/FormRequest.d.ts +2 -0
- package/core/FormRequest.d.ts.map +1 -0
- package/{FormRequest.js → core/FormRequest.js} +1 -1
- package/core/cli.d.ts +2 -0
- package/core/cli.d.ts.map +1 -0
- package/{cli.js → core/cli.js} +1 -1
- package/core/http.d.ts +2 -0
- package/core/http.d.ts.map +1 -0
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/inertia/index.d.ts +2 -0
- package/inertia/index.d.ts.map +1 -0
- package/inertia/index.js +17 -0
- package/lib/Command-Line/files/Controller.js +1 -1
- package/lib/Command-Line/files/Request.js +2 -2
- package/lib/Command-Line/files/ResourcesController.d.ts.map +1 -1
- package/lib/Command-Line/files/ResourcesController.js +2 -1
- package/lib/Dependancy/index.d.ts +1 -1
- package/lib/Dependancy/index.d.ts.map +1 -1
- package/lib/Dependancy/index.js +15 -5
- package/lib/Error/public/error.html +67 -192
- package/lib/Interface/index.d.ts +2 -0
- package/lib/Interface/index.d.ts.map +1 -1
- package/lib/Interface/index.js +6 -0
- package/lib/Middlewares/inertia.d.ts +7 -0
- package/lib/Middlewares/inertia.d.ts.map +1 -0
- package/lib/Middlewares/inertia.js +41 -0
- package/lib/Request/FormRequest.d.ts +1 -1
- package/lib/Request/FormRequest.d.ts.map +1 -1
- package/lib/Routes/RouteBuilder.d.ts +1 -1
- package/lib/Routes/RouteBuilder.d.ts.map +1 -1
- package/lib/Routes/RouteBuilder.js +41 -19
- package/lib/Routes/Router.d.ts.map +1 -1
- package/lib/Routes/Router.js +3 -1
- package/lib/Services/ServiceContainer.d.ts.map +1 -1
- package/lib/Services/ServiceContainer.js +8 -6
- package/lib/Services/ServiceProvider.d.ts +1 -1
- package/lib/Services/ServiceProvider.d.ts.map +1 -1
- package/package.json +1 -1
- package/Container.d.ts.map +0 -1
- package/Dependency.d.ts +0 -2
- package/Dependency.d.ts.map +0 -1
- package/FormRequest.d.ts +0 -2
- package/FormRequest.d.ts.map +0 -1
- package/cli.d.ts +0 -2
- package/cli.d.ts.map +0 -1
- package/http.d.ts +0 -2
- package/http.d.ts.map +0 -1
- /package/{Container.d.ts → core/Container.d.ts} +0 -0
- /package/{Container.js → core/Container.js} +0 -0
- /package/{http.js → core/http.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../framework/core/Container.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE9C;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAEnD;;;;;OAKG;IACH,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IAE3B;;;;;;;OAOG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAE9C;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE1B;;;;OAIG;IACH,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IAExB;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dependency.d.ts","sourceRoot":"","sources":["../../framework/core/Dependency.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("
|
|
17
|
+
__exportStar(require("../lib/Dependancy"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormRequest.d.ts","sourceRoot":"","sources":["../../framework/core/FormRequest.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("
|
|
17
|
+
__exportStar(require("../lib/Request/FormRequest"), exports);
|
package/core/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../framework/core/cli.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
|
package/{cli.js → core/cli.js}
RENAMED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("
|
|
17
|
+
__exportStar(require("../lib/Command-Line/NodeArtisanCommand"), exports);
|
|
18
18
|
// export * from "./lib/Command-Line/NodeTinker/TinkerCommand";
|
package/core/http.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../framework/core/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,IAAI,OAAO,EACrB,WAAW,IAAI,QAAQ,EACvB,OAAO,IAAI,IAAI,GAChB,MAAM,kBAAkB,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { bcrypt as appBcrypt, verifyHash as appVerifyHash, jwtSign as appJwtSign
|
|
|
5
5
|
export declare const HttpKernel: typeof Kernel;
|
|
6
6
|
export declare const config: typeof appConfig;
|
|
7
7
|
export declare const Auth: typeof Authentication;
|
|
8
|
-
export declare const auth: (request: import("./
|
|
9
|
-
export declare const guest: (req: import("./
|
|
10
|
-
export declare const apiAuth: (request: import("./
|
|
8
|
+
export declare const auth: (request: import("./lib/Interface").AppRequest, response: import("./lib/Interface").AppResponse, next: import("./lib/Interface").AppNext) => any;
|
|
9
|
+
export declare const guest: (req: import("./lib/Interface").AppRequest, res: import("./lib/Interface").AppResponse, next: import("./lib/Interface").AppNext) => any;
|
|
10
|
+
export declare const apiAuth: (request: import("./lib/Interface").AppRequest, response: import("./lib/Interface").AppResponse, next: import("./lib/Interface").AppNext) => Promise<any>;
|
|
11
11
|
export declare const bcrypt: typeof appBcrypt;
|
|
12
12
|
export declare const jwtSign: typeof appJwtSign;
|
|
13
13
|
export declare const jwtVerify: typeof appjwtVerify;
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../framework/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,MAAM,MAAM,6BAA6B,CAAC;AACjD,OAAO,cAAc,MAAM,YAAY,CAAC;AAKxC,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,UAAU,IAAI,aAAa,EAC3B,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"index.d.ts","sourceRoot":"","sources":["../../framework/inertia/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/inertia/index.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/Middlewares/inertia"), exports);
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
*/
|
|
8
8
|
const createController = (name) => {
|
|
9
9
|
return `
|
|
10
|
-
import {Request, Response,Next} from "jcc-express-mvc/http"
|
|
10
|
+
import {Request, Response,Next} from "jcc-express-mvc/core/http"
|
|
11
11
|
|
|
12
12
|
export class ${name}{
|
|
13
13
|
/**
|
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
*/
|
|
8
8
|
const createRequest = (fileName) => {
|
|
9
9
|
return `
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import { FormRequest } from "jcc-express-mvc/core/FormRequest";
|
|
11
|
+
import {Request} from "jcc-express-mvc/core/http"
|
|
12
12
|
|
|
13
13
|
export class ${fileName} extends FormRequest {
|
|
14
14
|
constructor(req:Request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourcesController.d.ts","sourceRoot":"","sources":["../../../../framework/lib/Command-Line/files/ResourcesController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,eAAgB,MAAM,UAAU,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"ResourcesController.d.ts","sourceRoot":"","sources":["../../../../framework/lib/Command-Line/files/ResourcesController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,eAAgB,MAAM,UAAU,MAAM,GAAG,OAAO,WAqEvE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
* @returns string
|
|
7
7
|
*/
|
|
8
8
|
const resourceController = (controller, model) => {
|
|
9
|
-
return `
|
|
9
|
+
return `
|
|
10
|
+
import {Model}= from "jcc-eloquent"
|
|
10
11
|
export class ${controller} extends Model {
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
export declare function Inject(
|
|
2
|
+
export declare function Inject(): ClassDecorator;
|
|
3
3
|
export declare function Injectable(singleton?: boolean): ClassDecorator;
|
|
4
4
|
export declare const app: import("../Services/ServiceContainer").ServiceContainer;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../framework/lib/Dependancy/index.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../framework/lib/Dependancy/index.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAiB1B,wBAAgB,MAAM,IAAI,cAAc,CAIvC;AAED,wBAAgB,UAAU,CAAC,SAAS,GAAE,OAAe,GAAG,cAAc,CAOrE;AAED,eAAO,MAAM,GAAG,yDAAyB,CAAC"}
|
package/lib/Dependancy/index.js
CHANGED
|
@@ -6,11 +6,21 @@ exports.Injectable = Injectable;
|
|
|
6
6
|
const App_1 = require("../App");
|
|
7
7
|
require("reflect-metadata");
|
|
8
8
|
//
|
|
9
|
-
function Inject(serviceName) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
// export function Inject(serviceName?: string): ParameterDecorator {
|
|
10
|
+
// return (
|
|
11
|
+
// target: Object,
|
|
12
|
+
// propertyKey: string | symbol | undefined,
|
|
13
|
+
// parameterIndex: number,
|
|
14
|
+
// ) => {
|
|
15
|
+
// const existingInjectedParameters =
|
|
16
|
+
// Reflect.getMetadata("inject_params", target) || [];
|
|
17
|
+
// existingInjectedParameters[parameterIndex] = { serviceName };
|
|
18
|
+
// Reflect.defineMetadata("inject_params", existingInjectedParameters, target);
|
|
19
|
+
// };
|
|
20
|
+
// }
|
|
21
|
+
function Inject() {
|
|
22
|
+
return (target) => {
|
|
23
|
+
Reflect.defineMetadata("inject", target.name, target);
|
|
14
24
|
};
|
|
15
25
|
}
|
|
16
26
|
function Injectable(singleton = false) {
|
|
@@ -14,204 +14,79 @@
|
|
|
14
14
|
<body class="">
|
|
15
15
|
<div class="code-container">
|
|
16
16
|
<div class="error-message">
|
|
17
|
-
|
|
18
|
-
Require stack:
|
|
19
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/node_modules/express/lib/view.js
|
|
20
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/node_modules/express/lib/application.js
|
|
21
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/node_modules/express/lib/express.js
|
|
22
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/node_modules/express/index.js
|
|
23
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/framework/lib/Server/index.ts
|
|
24
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/framework/lib/App.ts
|
|
25
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/framework/server.ts
|
|
26
|
-
- /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/server.ts <p> /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/node_modules/express/lib/view.js undefined:undefined </p>
|
|
17
|
+
injectParams.map is not a function <p> /home/abdou/Documents/GAMBTECH/FRAMEWORK/jcc/framework/lib/Services/ServiceContainer.ts 55:31 </p>
|
|
27
18
|
</div>
|
|
28
19
|
<div class="container">
|
|
29
20
|
<pre
|
|
30
|
-
data-line="
|
|
21
|
+
data-line="55"
|
|
31
22
|
class="line-numbers"
|
|
32
|
-
><code class="language-javascript">1.
|
|
33
|
-
2.
|
|
34
|
-
3.
|
|
35
|
-
4.
|
|
36
|
-
5.
|
|
37
|
-
6.
|
|
38
|
-
7.
|
|
39
|
-
8.
|
|
40
|
-
9.
|
|
23
|
+
><code class="language-javascript">1. import "reflect-metadata";
|
|
24
|
+
2. export class ServiceContainer {
|
|
25
|
+
3. private bindings: Map<string, any> = new Map();
|
|
26
|
+
4. private instances: Map<string, any> = new Map();
|
|
27
|
+
5.
|
|
28
|
+
6. // Bind a service to the container
|
|
29
|
+
7. public bind<T>(key: string, resolver: () => T): void {
|
|
30
|
+
8. this.bindings.set(key, resolver);
|
|
31
|
+
9. }
|
|
41
32
|
10.
|
|
42
|
-
11.
|
|
43
|
-
12.
|
|
44
|
-
13.
|
|
45
|
-
14.
|
|
46
|
-
15.
|
|
47
|
-
16.
|
|
48
|
-
17.
|
|
49
|
-
18.
|
|
50
|
-
19.
|
|
51
|
-
20.
|
|
52
|
-
21.
|
|
53
|
-
22.
|
|
54
|
-
23.
|
|
55
|
-
24.
|
|
56
|
-
25.
|
|
57
|
-
26.
|
|
58
|
-
27.
|
|
59
|
-
28.
|
|
60
|
-
29.
|
|
33
|
+
11. // Bind a singleton service to the container
|
|
34
|
+
12. public singleton<T>(key: string, resolver: () => T): void {
|
|
35
|
+
13. this.bindings.set(key, () => {
|
|
36
|
+
14. if (!this.instances.has(key)) {
|
|
37
|
+
15. const instance = resolver();
|
|
38
|
+
16. this.instances.set(key, instance);
|
|
39
|
+
17. }
|
|
40
|
+
18. return this.instances.get(key);
|
|
41
|
+
19. });
|
|
42
|
+
20. }
|
|
43
|
+
21.
|
|
44
|
+
22. // Resolve a service from the container
|
|
45
|
+
23. public resolve<T>(key: string): T | undefined {
|
|
46
|
+
24. if (this.bindings.has(key)) {
|
|
47
|
+
25. const resolver = this.bindings.get(key);
|
|
48
|
+
26. return resolver();
|
|
49
|
+
27. }
|
|
50
|
+
28. return undefined;
|
|
51
|
+
29. }
|
|
61
52
|
30.
|
|
62
|
-
31.
|
|
63
|
-
32.
|
|
64
|
-
33.
|
|
65
|
-
34.
|
|
66
|
-
35.
|
|
67
|
-
36.
|
|
68
|
-
37.
|
|
69
|
-
38.
|
|
70
|
-
39.
|
|
71
|
-
40.
|
|
72
|
-
41.
|
|
73
|
-
42.
|
|
74
|
-
43.
|
|
75
|
-
44.
|
|
76
|
-
45.
|
|
77
|
-
46.
|
|
78
|
-
47.
|
|
79
|
-
48.
|
|
80
|
-
49.
|
|
81
|
-
50.
|
|
82
|
-
51.
|
|
83
|
-
52.
|
|
84
|
-
53.
|
|
85
|
-
54.
|
|
86
|
-
55.
|
|
87
|
-
56.
|
|
88
|
-
57.
|
|
89
|
-
58.
|
|
90
|
-
59.
|
|
91
|
-
60.
|
|
92
|
-
61.
|
|
93
|
-
62.
|
|
94
|
-
63.
|
|
95
|
-
64.
|
|
96
|
-
65.
|
|
97
|
-
66.
|
|
98
|
-
67.
|
|
99
|
-
68. this.ext = this.defaultEngine[0] !== '.'
|
|
100
|
-
69. ? '.' + this.defaultEngine
|
|
101
|
-
70. : this.defaultEngine;
|
|
102
|
-
71.
|
|
103
|
-
72. fileName += this.ext;
|
|
104
|
-
73. }
|
|
105
|
-
74.
|
|
106
|
-
75. if (!opts.engines[this.ext]) {
|
|
107
|
-
76. // load engine
|
|
108
|
-
77. var mod = this.ext.slice(1)
|
|
109
|
-
78. debug('require "%s"', mod)
|
|
110
|
-
79.
|
|
111
|
-
80. // default engine export
|
|
112
|
-
81. var fn = require(mod).__express
|
|
113
|
-
82.
|
|
114
|
-
83. if (typeof fn !== 'function') {
|
|
115
|
-
84. throw new Error('Module "' + mod + '" does not provide a view engine.')
|
|
116
|
-
85. }
|
|
117
|
-
86.
|
|
118
|
-
87. opts.engines[this.ext] = fn
|
|
119
|
-
88. }
|
|
120
|
-
89.
|
|
121
|
-
90. // store loaded engine
|
|
122
|
-
91. this.engine = opts.engines[this.ext];
|
|
123
|
-
92.
|
|
124
|
-
93. // lookup path
|
|
125
|
-
94. this.path = this.lookup(fileName);
|
|
126
|
-
95. }
|
|
127
|
-
96.
|
|
128
|
-
97. /**
|
|
129
|
-
98. * Lookup view by the given `name`
|
|
130
|
-
99. *
|
|
131
|
-
100. * @param {string} name
|
|
132
|
-
101. * @private
|
|
133
|
-
102. */
|
|
134
|
-
103.
|
|
135
|
-
104. View.prototype.lookup = function lookup(name) {
|
|
136
|
-
105. var path;
|
|
137
|
-
106. var roots = [].concat(this.root);
|
|
138
|
-
107.
|
|
139
|
-
108. debug('lookup "%s"', name);
|
|
140
|
-
109.
|
|
141
|
-
110. for (var i = 0; i < roots.length && !path; i++) {
|
|
142
|
-
111. var root = roots[i];
|
|
143
|
-
112.
|
|
144
|
-
113. // resolve the path
|
|
145
|
-
114. var loc = resolve(root, name);
|
|
146
|
-
115. var dir = dirname(loc);
|
|
147
|
-
116. var file = basename(loc);
|
|
148
|
-
117.
|
|
149
|
-
118. // resolve the file
|
|
150
|
-
119. path = this.resolve(dir, file);
|
|
151
|
-
120. }
|
|
152
|
-
121.
|
|
153
|
-
122. return path;
|
|
154
|
-
123. };
|
|
155
|
-
124.
|
|
156
|
-
125. /**
|
|
157
|
-
126. * Render with the given options.
|
|
158
|
-
127. *
|
|
159
|
-
128. * @param {object} options
|
|
160
|
-
129. * @param {function} callback
|
|
161
|
-
130. * @private
|
|
162
|
-
131. */
|
|
163
|
-
132.
|
|
164
|
-
133. View.prototype.render = function render(options, callback) {
|
|
165
|
-
134. debug('render "%s"', this.path);
|
|
166
|
-
135. this.engine(this.path, options, callback);
|
|
167
|
-
136. };
|
|
168
|
-
137.
|
|
169
|
-
138. /**
|
|
170
|
-
139. * Resolve the file within the given directory.
|
|
171
|
-
140. *
|
|
172
|
-
141. * @param {string} dir
|
|
173
|
-
142. * @param {string} file
|
|
174
|
-
143. * @private
|
|
175
|
-
144. */
|
|
176
|
-
145.
|
|
177
|
-
146. View.prototype.resolve = function resolve(dir, file) {
|
|
178
|
-
147. var ext = this.ext;
|
|
179
|
-
148.
|
|
180
|
-
149. // <path>.<ext>
|
|
181
|
-
150. var path = join(dir, file);
|
|
182
|
-
151. var stat = tryStat(path);
|
|
183
|
-
152.
|
|
184
|
-
153. if (stat && stat.isFile()) {
|
|
185
|
-
154. return path;
|
|
186
|
-
155. }
|
|
187
|
-
156.
|
|
188
|
-
157. // <path>/index.<ext>
|
|
189
|
-
158. path = join(dir, basename(file, ext), 'index' + ext);
|
|
190
|
-
159. stat = tryStat(path);
|
|
191
|
-
160.
|
|
192
|
-
161. if (stat && stat.isFile()) {
|
|
193
|
-
162. return path;
|
|
194
|
-
163. }
|
|
195
|
-
164. };
|
|
196
|
-
165.
|
|
197
|
-
166. /**
|
|
198
|
-
167. * Return a stat, maybe.
|
|
199
|
-
168. *
|
|
200
|
-
169. * @param {string} path
|
|
201
|
-
170. * @return {fs.Stats}
|
|
202
|
-
171. * @private
|
|
203
|
-
172. */
|
|
204
|
-
173.
|
|
205
|
-
174. function tryStat(path) {
|
|
206
|
-
175. debug('stat "%s"', path);
|
|
207
|
-
176.
|
|
208
|
-
177. try {
|
|
209
|
-
178. return fs.statSync(path);
|
|
210
|
-
179. } catch (e) {
|
|
211
|
-
180. return undefined;
|
|
212
|
-
181. }
|
|
213
|
-
182. }
|
|
214
|
-
183. </code></pre>
|
|
53
|
+
31. // Call a method on a service and automatically resolve its dependencies
|
|
54
|
+
32. public call<T>(method: string, ...args: any[]): T {
|
|
55
|
+
33. if (typeof this.instances.get(method) !== "function") {
|
|
56
|
+
34. throw new Error(`Method "${method}" not found on service`);
|
|
57
|
+
35. }
|
|
58
|
+
36. return this.instances.get(method)(...args);
|
|
59
|
+
37. }
|
|
60
|
+
38. // Alias for resolving a service
|
|
61
|
+
39. public make<T>(key: string): T | undefined {
|
|
62
|
+
40. return this.resolve<T>(key);
|
|
63
|
+
41. }
|
|
64
|
+
42.
|
|
65
|
+
43. public alias(key: string, alias: string): void {
|
|
66
|
+
44. if (!this.bindings.has(key)) {
|
|
67
|
+
45. throw new Error(`Service "${key}" not found`);
|
|
68
|
+
46. }
|
|
69
|
+
47. this.bindings.set(alias, this.bindings.get(key));
|
|
70
|
+
48. }
|
|
71
|
+
49.
|
|
72
|
+
50. public resolveDynamicInjection<T>(target: new (...args: any[]) => T): T {
|
|
73
|
+
51. Reflect.defineMetadata("design:paramtypes", target, target);
|
|
74
|
+
52. const injectParams = Reflect.getMetadata("design:paramtypes", target) || [];
|
|
75
|
+
53.
|
|
76
|
+
54. console.log({ injectParams });
|
|
77
|
+
55. const args = injectParams.map((param: any) => {
|
|
78
|
+
56. // const service = this.resolve(param.serviceName);
|
|
79
|
+
57. // if (!service) {
|
|
80
|
+
58. // throw new Error(`Service ${param.serviceName} not found`);
|
|
81
|
+
59. // }
|
|
82
|
+
60. // return service;
|
|
83
|
+
61. });
|
|
84
|
+
62.
|
|
85
|
+
63. // Instantiate the class with the resolved dependencies
|
|
86
|
+
64. return new target(...args);
|
|
87
|
+
65. }
|
|
88
|
+
66. }
|
|
89
|
+
67. </code></pre>
|
|
215
90
|
</div>
|
|
216
91
|
</div>
|
|
217
92
|
<script src="/js/app-error-prism.js"> </script>
|
package/lib/Interface/index.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface AppRequest extends Request {
|
|
|
37
37
|
}
|
|
38
38
|
export interface AppResponse extends Response {
|
|
39
39
|
redirectBack: () => any;
|
|
40
|
+
inertia: (component: any, props?: {}, option?: {}) => any | void;
|
|
41
|
+
inertiaRedirect: (url: string, message?: string, type?: string) => void;
|
|
40
42
|
}
|
|
41
43
|
export interface AppNext extends NextFunction {
|
|
42
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../framework/lib/Interface/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,MAAM,WAAW,eAAe;IAC9B,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,GAAG,GAAG,CAAC;CACvE;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,cAAc,CAAC;CACxE;AAED,MAAM,WAAW,UAAW,SAAQ,OAAO;IAEzC,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChC,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,KAAK,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC;IACrC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;IACxD,KAAK,CAAC,IAAI,EA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,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C;AAED,MAAM,WAAW,UAAU;CAAG"}
|
package/lib/Interface/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppRequest, AppResponse, AppNext } from "../Interface";
|
|
2
|
+
interface InertiaOptions {
|
|
3
|
+
rootView: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const inertia: (options: InertiaOptions) => (req: AppRequest, res: AppResponse, next: AppNext) => void;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=inertia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inertia.d.ts","sourceRoot":"","sources":["../../../framework/lib/Middlewares/inertia.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEhE,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4CD,eAAO,MAAM,OAAO,YAAa,cAAc,WA/B9B,UAAU,OAAO,WAAW,QAAQ,OAAO,SAgCxB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inertia = void 0;
|
|
4
|
+
class InertiaMiddleware {
|
|
5
|
+
shareProps(req, res, props) {
|
|
6
|
+
const errors = {
|
|
7
|
+
...res.locals.errors,
|
|
8
|
+
...(res.locals.error?.email ? res.locals.error : {}),
|
|
9
|
+
}; //{ ...(appValidationError || res.locals.error) };
|
|
10
|
+
const auth = { ...req.user };
|
|
11
|
+
return { ...props, auth, errors };
|
|
12
|
+
}
|
|
13
|
+
inertia(options) {
|
|
14
|
+
return (req, res, next) => {
|
|
15
|
+
res.inertia = (component, props = {}, option = {}) => {
|
|
16
|
+
const isInertiaRequest = req.header("X-Inertia");
|
|
17
|
+
const sharedProps = this.shareProps(req, res, props);
|
|
18
|
+
if (isInertiaRequest) {
|
|
19
|
+
res.setHeader("X-Inertia", "true");
|
|
20
|
+
return res.json({
|
|
21
|
+
component,
|
|
22
|
+
props: sharedProps,
|
|
23
|
+
url: req.url,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
res.render(options.rootView, {
|
|
27
|
+
inertia: JSON.stringify({
|
|
28
|
+
component,
|
|
29
|
+
props: sharedProps,
|
|
30
|
+
url: req.url,
|
|
31
|
+
}),
|
|
32
|
+
option,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
next();
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const inertiaMiddleware = new InertiaMiddleware();
|
|
40
|
+
const inertia = (options) => inertiaMiddleware.inertia(options);
|
|
41
|
+
exports.inertia = inertia;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRequest.d.ts","sourceRoot":"","sources":["../../../framework/lib/Request/FormRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,
|
|
1
|
+
{"version":3,"file":"FormRequest.d.ts","sourceRoot":"","sources":["../../../framework/lib/Request/FormRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,8BAAsB,WAAW;IAC/B,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,OAAO,CAAC,WAAW,CAAM;gBACb,GAAG,EAAE,UAAU;IAO3B;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAIlC;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIrC;;;;OAIG;IACH,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIxC;;;OAGG;IACH,SAAS,CAAC,OAAO,IAAI,UAAU;IAI/B;;;;OAIG;cACa,QAAQ,CACtB,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAInC;;;;OAIG;cACa,WAAW,CACzB,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAInC;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK5B;;;;;OAKG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/C;;;;;OAKG;IACG,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC;CAK3C"}
|
|
@@ -16,7 +16,7 @@ export declare class RouteBuilder {
|
|
|
16
16
|
*/
|
|
17
17
|
protected resolvePath(path: string): string;
|
|
18
18
|
static controllerMethods(url: string): MethodsInterface;
|
|
19
|
-
static validateResourceOption(option: ResourceOption, methods:
|
|
19
|
+
static validateResourceOption(option: ResourceOption, methods: ObjectType): boolean | ObjectType;
|
|
20
20
|
/**
|
|
21
21
|
* Replaces route parameters enclosed in curly braces with corresponding placeholders.
|
|
22
22
|
* For example, converts "{name}" to ":name".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteBuilder.d.ts","sourceRoot":"","sources":["../../../framework/lib/Routes/RouteBuilder.ts"],"names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AAC,WAAW;IAgBZ,UAAU,CAAC,CAAC,EACjB,UAAU,EAAE,MAAM,WAAW,EAC7B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,cAAc,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;IAczC,iBAAiB,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;IAIrE,OAAO,CAAC,cAAc;CAmBvB"}
|
|
@@ -39,23 +39,42 @@ class RouteBuilder {
|
|
|
39
39
|
destroy: { uri: `${uri}/{id}`, method: "delete" },
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
+
// public static validateResourceOption(
|
|
43
|
+
// option: ResourceOption,
|
|
44
|
+
// methods: any,
|
|
45
|
+
// ): boolean | ObjectType {
|
|
46
|
+
// if (!option.only && !option.except) {
|
|
47
|
+
// return false;
|
|
48
|
+
// }
|
|
49
|
+
// if (option.except && option.except.length > 0) {
|
|
50
|
+
// option.except.forEach((method: string) => {
|
|
51
|
+
// delete methods[method];
|
|
52
|
+
// });
|
|
53
|
+
// }
|
|
54
|
+
// if (option.only && option.only.length > 0) {
|
|
55
|
+
// const filteredMethods: ObjectType = {};
|
|
56
|
+
// option.only.forEach((method: string) => {
|
|
57
|
+
// if (methods[method]) {
|
|
58
|
+
// filteredMethods[method] = methods[method];
|
|
59
|
+
// }
|
|
60
|
+
// });
|
|
61
|
+
// methods = filteredMethods;
|
|
62
|
+
// }
|
|
63
|
+
// return methods;
|
|
64
|
+
// }
|
|
42
65
|
static validateResourceOption(option, methods) {
|
|
43
66
|
if (!option.only && !option.except) {
|
|
44
67
|
return false;
|
|
45
68
|
}
|
|
46
|
-
if (option.except
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
69
|
+
if (option.except?.length) {
|
|
70
|
+
methods = Object.keys(methods)
|
|
71
|
+
.filter((method) => !option.except.includes(method))
|
|
72
|
+
.reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {});
|
|
50
73
|
}
|
|
51
|
-
if (option.only
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
filteredMethods[method] = methods[method];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
methods = filteredMethods;
|
|
74
|
+
if (option.only?.length) {
|
|
75
|
+
methods = option.only
|
|
76
|
+
.filter((method) => methods[method])
|
|
77
|
+
.reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {});
|
|
59
78
|
}
|
|
60
79
|
return methods;
|
|
61
80
|
}
|
|
@@ -107,6 +126,7 @@ class RouteBuilder {
|
|
|
107
126
|
if (callback.length == 2) {
|
|
108
127
|
const [Controller, method] = callback;
|
|
109
128
|
const instance = this.resolveController(Controller);
|
|
129
|
+
// const instance = new Controller();
|
|
110
130
|
return instance[method].bind(instance);
|
|
111
131
|
}
|
|
112
132
|
throw new AppError_1.AppError(`Method not define ${callback[0]}`, error_1.ROUTE_CALLBACK_ERROR);
|
|
@@ -122,15 +142,20 @@ class RouteBuilder {
|
|
|
122
142
|
* @param {string} url - The route path.
|
|
123
143
|
* @param {string} callback - The callback function or method name.
|
|
124
144
|
*/
|
|
125
|
-
createRoute(httpMethod, url, middleware,
|
|
126
|
-
return this.app[httpMethod](this.resolvePath(url), middleware, (0, util_1.asyncHandler)(
|
|
145
|
+
createRoute(httpMethod, url, middleware, handlerResolver) {
|
|
146
|
+
return this.app[httpMethod](this.resolvePath(url), middleware, (0, util_1.asyncHandler)((req, res, next) => {
|
|
147
|
+
const handler = handlerResolver();
|
|
148
|
+
return handler(req, res, next);
|
|
149
|
+
}));
|
|
127
150
|
}
|
|
128
151
|
buildRoute(httpMethod, url, callback) {
|
|
129
152
|
try {
|
|
130
153
|
const middleware = RouteBuilder.middleware || [];
|
|
131
154
|
RouteBuilder.middleware = [];
|
|
132
|
-
const handler = this.resolveHandler(callback);
|
|
133
|
-
|
|
155
|
+
// const handler = this.resolveHandler(callback);
|
|
156
|
+
const handlerResolver = () => this.resolveHandler(callback);
|
|
157
|
+
// return this.createRoute(httpMethod, url, middleware, handler);
|
|
158
|
+
return this.createRoute(httpMethod, url, middleware, handlerResolver);
|
|
134
159
|
}
|
|
135
160
|
catch (error) {
|
|
136
161
|
throw new AppError_1.AppError(error.message, error_1.ROUTE_BUILDER_ERROR);
|
|
@@ -142,10 +167,7 @@ class RouteBuilder {
|
|
|
142
167
|
resolveHandler(callback) {
|
|
143
168
|
if (this.hasController() && typeof callback === "string") {
|
|
144
169
|
const Controller = RouteBuilder.controller;
|
|
145
|
-
// this.serviceContainer.singleton(Controller.name, () => new Controller());
|
|
146
170
|
const instance = this.resolveController(Controller);
|
|
147
|
-
//new Controller();
|
|
148
|
-
// Ensure the method exists on the instance
|
|
149
171
|
if (typeof instance[callback] !== "function") {
|
|
150
172
|
throw new AppError_1.AppError(`Method ${callback} not found on controller`, error_1.ROUTE_CALLBACK_ERROR);
|
|
151
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../../framework/lib/Routes/Router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,WAAW,EAA8B,MAAM,SAAS,CAAC;AAE3E,qBAAa,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAc;IAEzB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,OAAO,CAAU;gBAIb,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO;IAO/C;;;;OAIG;IACI,UAAU,CAAC,UAAU,EAAE,GAAG,GAAG,IAAI;IAKxC;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKhC;;;;OAIG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AAC,EACV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,GAC9C,CAAC;IAIJ;;;;;OAKG;IACI,MAAM,CAAC,CAAC,EACb,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,GAC9C,CAAC;IAIG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAM7C,QAAQ,CACb,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,EAC5B,MAAM,GAAE,cAAyC;IAYnD,OAAO,CAAC,mBAAmB;CAS5B"}
|
package/lib/Routes/Router.js
CHANGED
|
@@ -107,7 +107,9 @@ class Router {
|
|
|
107
107
|
for (const key in methods) {
|
|
108
108
|
const method = methods[key].method;
|
|
109
109
|
const path = methods[key].uri;
|
|
110
|
-
|
|
110
|
+
const uri = this.appPath.basePath + path;
|
|
111
|
+
// console.log({ text: uri.trim(), method });
|
|
112
|
+
this[method](this.appPath.basePath + path, key);
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceContainer.d.ts","sourceRoot":"","sources":["../../../framework/lib/Services/ServiceContainer.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,SAAS,CAA+B;IAGzC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI;IAK7C,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI;IAWlD,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAStC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"ServiceContainer.d.ts","sourceRoot":"","sources":["../../../framework/lib/Services/ServiceContainer.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,SAAS,CAA+B;IAGzC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI;IAK7C,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI;IAWlD,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAStC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC;IAQ1C,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAInC,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;CAiBxE"}
|
|
@@ -47,15 +47,17 @@ class ServiceContainer {
|
|
|
47
47
|
this.bindings.set(alias, this.bindings.get(key));
|
|
48
48
|
}
|
|
49
49
|
resolveDynamicInjection(target) {
|
|
50
|
-
const injectParams = Reflect.getMetadata("
|
|
51
|
-
const args = injectParams.map((
|
|
52
|
-
|
|
53
|
-
if (!service) {
|
|
54
|
-
|
|
50
|
+
const injectParams = Reflect.getMetadata("design:paramtypes", target) || [];
|
|
51
|
+
const args = injectParams.map((Constructor) => {
|
|
52
|
+
let service = this.resolve(Constructor.name);
|
|
53
|
+
if (!service && typeof Constructor == "function") {
|
|
54
|
+
service = new Constructor();
|
|
55
|
+
}
|
|
56
|
+
if (!service && !Constructor) {
|
|
57
|
+
throw new Error(`Service ${Constructor.name} not found`);
|
|
55
58
|
}
|
|
56
59
|
return service;
|
|
57
60
|
});
|
|
58
|
-
// Instantiate the class with the resolved dependencies
|
|
59
61
|
return new target(...args);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceProvider.d.ts","sourceRoot":"","sources":["../../../framework/lib/Services/ServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ServiceProvider.d.ts","sourceRoot":"","sources":["../../../framework/lib/Services/ServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,8BAAsB,eAAe;IAEnC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;IAEzB,SAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAM;IAE5C,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC,GAAG,CAAC,CAAM;IAE3C,OAAc,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAM;IAEzC,OAAc,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAM;gBAEjC,GAAG,EAAE,SAAS;IAInB,QAAQ,IAAI,IAAI;IAEhB,IAAI,IAAI,IAAI;IAEZ,OAAO,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAI5B,MAAM,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAI3B,oBAAoB,IAAI,IAAI;IAM5B,mBAAmB,IAAI,IAAI;CAKnC"}
|
package/package.json
CHANGED
package/Container.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../framework/Container.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE9C;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAEnD;;;;;OAKG;IACH,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IAE3B;;;;;;;OAOG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAE9C;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE1B;;;;OAIG;IACH,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IAExB;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC"}
|
package/Dependency.d.ts
DELETED
package/Dependency.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Dependency.d.ts","sourceRoot":"","sources":["../framework/Dependency.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/FormRequest.d.ts
DELETED
package/FormRequest.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormRequest.d.ts","sourceRoot":"","sources":["../framework/FormRequest.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/cli.d.ts
DELETED
package/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../framework/cli.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC"}
|
package/http.d.ts
DELETED
package/http.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../framework/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,IAAI,OAAO,EACrB,WAAW,IAAI,QAAQ,EACvB,OAAO,IAAI,IAAI,GAChB,MAAM,iBAAiB,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|