jcc-express-mvc 1.4.7 → 1.4.9
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/Str.d.ts +2 -0
- package/core/Str.d.ts.map +1 -0
- package/core/Str.js +17 -0
- package/lib/Command-Line/files/Request.js +1 -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 +1 -0
- package/lib/Interface/index.d.ts.map +1 -1
- package/lib/Middlewares/inertia.d.ts.map +1 -1
- package/lib/Middlewares/inertia.js +15 -5
- package/lib/Request/FormRequest.d.ts +2 -2
- package/lib/Request/FormRequest.d.ts.map +1 -1
- package/lib/Request/FormRequest.js +2 -2
- package/lib/Routes/RouteBuilder.d.ts.map +1 -1
- package/lib/Routes/RouteBuilder.js +2 -6
- package/lib/Services/ServiceContainer.d.ts.map +1 -1
- package/lib/Services/ServiceContainer.js +8 -6
- package/lib/util/Str.d.ts +404 -0
- package/lib/util/Str.d.ts.map +1 -0
- package/lib/util/Str.js +576 -0
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +8 -3
- package/package.json +1 -1
package/core/Str.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Str.d.ts","sourceRoot":"","sources":["../../framework/core/Str.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/core/Str.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/util/Str"), exports);
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
const createRequest = (fileName) => {
|
|
9
9
|
return `
|
|
10
10
|
import { FormRequest } from "jcc-express-mvc/core/FormRequest";
|
|
11
|
-
import {Request} from "jcc-express-mvc/http"
|
|
11
|
+
import {Request} from "jcc-express-mvc/core/http"
|
|
12
12
|
|
|
13
13
|
export class ${fileName} extends FormRequest {
|
|
14
14
|
constructor(req:Request) {
|
|
@@ -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
|
@@ -38,6 +38,7 @@ export interface AppRequest extends Request {
|
|
|
38
38
|
export interface AppResponse extends Response {
|
|
39
39
|
redirectBack: () => any;
|
|
40
40
|
inertia: (component: any, props?: {}, option?: {}) => any | void;
|
|
41
|
+
inertiaRedirect: (url: string, message?: string, type?: string) => void;
|
|
41
42
|
}
|
|
42
43
|
export interface AppNext extends NextFunction {
|
|
43
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,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAA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MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,IAAI,EAAE;QAAE,GAAG,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"}
|
|
@@ -1 +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;
|
|
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;AA0DD,eAAO,MAAM,OAAO,YAAa,cAAc,WAzC9B,UAAU,OAAO,WAAW,QAAQ,OAAO,SA0CxB,CAAC"}
|
|
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.inertia = void 0;
|
|
4
4
|
class InertiaMiddleware {
|
|
5
5
|
shareProps(req, res, props) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
:
|
|
9
|
-
|
|
6
|
+
const errors = {
|
|
7
|
+
...res.locals.errors,
|
|
8
|
+
...(res.locals.error?.email ? res.locals.error : {}),
|
|
9
|
+
};
|
|
10
10
|
const auth = { ...req.user };
|
|
11
|
-
|
|
11
|
+
const flash = {
|
|
12
|
+
message: req.flash("success")[0] || req.flash("error")[0] || "",
|
|
13
|
+
status: res.statusCode,
|
|
14
|
+
};
|
|
15
|
+
return { ...props, auth, flash, errors };
|
|
12
16
|
}
|
|
13
17
|
inertia(options) {
|
|
14
18
|
return (req, res, next) => {
|
|
@@ -32,6 +36,12 @@ class InertiaMiddleware {
|
|
|
32
36
|
option,
|
|
33
37
|
});
|
|
34
38
|
};
|
|
39
|
+
res.inertiaRedirect = (url, message, type = "success") => {
|
|
40
|
+
if (message) {
|
|
41
|
+
req.flash(type, message);
|
|
42
|
+
}
|
|
43
|
+
return res.redirect(303, url);
|
|
44
|
+
};
|
|
35
45
|
next();
|
|
36
46
|
};
|
|
37
47
|
}
|
|
@@ -50,9 +50,9 @@ export declare abstract class FormRequest {
|
|
|
50
50
|
* Stores the uploaded file in the specified directory.
|
|
51
51
|
*
|
|
52
52
|
* @param {string} directory - The directory where the file should be stored.
|
|
53
|
-
* @returns {
|
|
53
|
+
* @returns {string} A promise that resolves when the file is saved.
|
|
54
54
|
*/
|
|
55
|
-
store(directory: string):
|
|
55
|
+
store(directory: string): string;
|
|
56
56
|
/**
|
|
57
57
|
* Uploads a file to Cloudinary.
|
|
58
58
|
*
|
|
@@ -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,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,C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AAU,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;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIhC;;;;;OAKG;IACG,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC;CAK3C"}
|
|
@@ -70,9 +70,9 @@ class FormRequest {
|
|
|
70
70
|
* Stores the uploaded file in the specified directory.
|
|
71
71
|
*
|
|
72
72
|
* @param {string} directory - The directory where the file should be stored.
|
|
73
|
-
* @returns {
|
|
73
|
+
* @returns {string} A promise that resolves when the file is saved.
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
store(directory) {
|
|
76
76
|
return (0, util_1.saveImage)(this.req, this.requestFile, directory);
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -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;AAEtD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,
|
|
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;AAEtD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU9C,qBAAa,YAAY;IACvB,OA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|
|
128
128
|
const instance = this.resolveController(Controller);
|
|
129
|
+
// const instance = new Controller();
|
|
129
130
|
return instance[method].bind(instance);
|
|
130
131
|
}
|
|
131
132
|
throw new AppError_1.AppError(`Method not define ${callback[0]}`, error_1.ROUTE_CALLBACK_ERROR);
|
|
@@ -141,9 +142,7 @@ class RouteBuilder {
|
|
|
141
142
|
* @param {string} url - The route path.
|
|
142
143
|
* @param {string} callback - The callback function or method name.
|
|
143
144
|
*/
|
|
144
|
-
createRoute(httpMethod, url, middleware,
|
|
145
|
-
// handler: RequestHandler,
|
|
146
|
-
handlerResolver) {
|
|
145
|
+
createRoute(httpMethod, url, middleware, handlerResolver) {
|
|
147
146
|
return this.app[httpMethod](this.resolvePath(url), middleware, (0, util_1.asyncHandler)((req, res, next) => {
|
|
148
147
|
const handler = handlerResolver();
|
|
149
148
|
return handler(req, res, next);
|
|
@@ -168,10 +167,7 @@ class RouteBuilder {
|
|
|
168
167
|
resolveHandler(callback) {
|
|
169
168
|
if (this.hasController() && typeof callback === "string") {
|
|
170
169
|
const Controller = RouteBuilder.controller;
|
|
171
|
-
// this.serviceContainer.singleton(Controller.name, () => new Controller());
|
|
172
170
|
const instance = this.resolveController(Controller);
|
|
173
|
-
//new Controller();
|
|
174
|
-
// Ensure the method exists on the instance
|
|
175
171
|
if (typeof instance[callback] !== "function") {
|
|
176
172
|
throw new AppError_1.AppError(`Method ${callback} not found on controller`, error_1.ROUTE_CALLBACK_ERROR);
|
|
177
173
|
}
|
|
@@ -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
|
}
|