fragment-ts 1.0.28 ā 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/init.command.js +1 -1
- package/dist/core/container/di-container.d.ts +7 -6
- package/dist/core/container/di-container.d.ts.map +1 -1
- package/dist/core/container/di-container.js +162 -129
- package/dist/core/container/di-container.js.map +1 -1
- package/dist/core/decorators/application.decorator.d.ts.map +1 -1
- package/dist/core/decorators/application.decorator.js +2 -1
- package/dist/core/decorators/application.decorator.js.map +1 -1
- package/dist/core/decorators/auto-configuration.decorator.d.ts.map +1 -1
- package/dist/core/decorators/auto-configuration.decorator.js +4 -3
- package/dist/core/decorators/auto-configuration.decorator.js.map +1 -1
- package/dist/core/decorators/controller.decorator.d.ts.map +1 -1
- package/dist/core/decorators/controller.decorator.js +1 -0
- package/dist/core/decorators/controller.decorator.js.map +1 -1
- package/dist/core/decorators/http.decorators.d.ts.map +1 -1
- package/dist/core/decorators/http.decorators.js +9 -0
- package/dist/core/decorators/http.decorators.js.map +1 -1
- package/dist/core/decorators/injectable.decorator.d.ts.map +1 -1
- package/dist/core/decorators/injectable.decorator.js +1 -0
- package/dist/core/decorators/injectable.decorator.js.map +1 -1
- package/dist/core/decorators/injection.decorators.d.ts.map +1 -1
- package/dist/core/decorators/injection.decorators.js +49 -19
- package/dist/core/decorators/injection.decorators.js.map +1 -1
- package/dist/core/decorators/repository.decorator.d.ts.map +1 -1
- package/dist/core/decorators/repository.decorator.js +1 -0
- package/dist/core/decorators/repository.decorator.js.map +1 -1
- package/dist/core/decorators/service.decorator.d.ts.map +1 -1
- package/dist/core/decorators/service.decorator.js +1 -0
- package/dist/core/decorators/service.decorator.js.map +1 -1
- package/dist/core/metadata/metadata-storage.d.ts +11 -0
- package/dist/core/metadata/metadata-storage.d.ts.map +1 -1
- package/dist/core/metadata/metadata-storage.js +22 -0
- package/dist/core/metadata/metadata-storage.js.map +1 -1
- package/dist/web/application.d.ts +0 -6
- package/dist/web/application.d.ts.map +1 -1
- package/dist/web/application.js +75 -38
- package/dist/web/application.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/init.command.ts +1 -1
- package/src/core/container/di-container.ts +247 -181
- package/src/core/decorators/application.decorator.ts +2 -1
- package/src/core/decorators/auto-configuration.decorator.ts +9 -8
- package/src/core/decorators/controller.decorator.ts +2 -1
- package/src/core/decorators/http.decorators.ts +17 -0
- package/src/core/decorators/injectable.decorator.ts +1 -0
- package/src/core/decorators/injection.decorators.ts +62 -22
- package/src/core/decorators/repository.decorator.ts +1 -0
- package/src/core/decorators/service.decorator.ts +1 -0
- package/src/core/metadata/metadata-storage.ts +47 -0
- package/src/web/application.ts +107 -64
- package/tsconfig.json +4 -3
|
@@ -6,6 +6,9 @@ const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
|
6
6
|
function createHttpMethodDecorator(method) {
|
|
7
7
|
return (path = "") => {
|
|
8
8
|
return (target, propertyKey, descriptor) => {
|
|
9
|
+
const className = target.constructor.name;
|
|
10
|
+
const methodName = String(propertyKey);
|
|
11
|
+
console.log(`ā” Registering ${method.toUpperCase()} route: ${className}.${methodName} at ${path || "/"}`);
|
|
9
12
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.HTTP_METHOD, method, target, propertyKey);
|
|
10
13
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.ROUTE_PATH, path, target, propertyKey);
|
|
11
14
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
@@ -30,6 +33,12 @@ function createParamDecorator(type) {
|
|
|
30
33
|
if (!propertyKey) {
|
|
31
34
|
throw new Error(`@${type}() cannot be used on constructor parameters`);
|
|
32
35
|
}
|
|
36
|
+
const className = target.constructor.name;
|
|
37
|
+
const methodName = String(propertyKey);
|
|
38
|
+
const paramDisplay = paramName
|
|
39
|
+
? `${paramName} (index: ${parameterIndex})`
|
|
40
|
+
: `index: ${parameterIndex}`;
|
|
41
|
+
console.log(` š„ Registering @${type} parameter for ${className}.${methodName}: ${paramDisplay}`);
|
|
33
42
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
34
43
|
storage.addParam({
|
|
35
44
|
target,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.decorators.js","sourceRoot":"","sources":["../../../src/core/decorators/http.decorators.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,mEAA+D;AAE/D,SAAS,yBAAyB,CAAC,MAAc;IAC/C,OAAO,CAAC,OAAe,EAAE,EAAmB,EAAE;QAC5C,OAAO,CACL,MAAW,EACX,WAA4B,EAC5B,UAA8B,EAC9B,EAAE;YACF,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,WAAW,EACzB,MAAM,EACN,MAAM,EACN,WAAW,CACZ,CAAC;YACF,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,UAAU,EACxB,IAAI,EACJ,MAAM,EACN,WAAW,CACZ,CAAC;YAEF,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,SAAS,CAAC;gBAChB,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,WAAW,EAAE,WAAqB;gBAClC,MAAM;gBACN,IAAI;gBACJ,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,WAAqB,CAAC;aAChE,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAEY,QAAA,GAAG,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;AACvC,QAAA,IAAI,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACzC,QAAA,GAAG,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;AACvC,QAAA,MAAM,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC7C,QAAA,KAAK,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAExD,SAAS,oBAAoB,CAAC,IAAY;IACxC,OAAO,CA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wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAmB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"injectable.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/injectable.decorator.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAE1D,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAmB,GAAG,cAAc,CAarE"}
|
|
@@ -5,6 +5,7 @@ const metadata_keys_1 = require("../metadata/metadata-keys");
|
|
|
5
5
|
const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
6
6
|
function Injectable(scope = 'singleton') {
|
|
7
7
|
return (target) => {
|
|
8
|
+
console.log(`š Registering Injectable: ${target.name} [${scope}]`);
|
|
8
9
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.INJECTABLE, true, target);
|
|
9
10
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.SCOPE, scope, target);
|
|
10
11
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectable.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/injectable.decorator.ts"],"names":[],"mappings":";;AAKA,
|
|
1
|
+
{"version":3,"file":"injectable.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/injectable.decorator.ts"],"names":[],"mappings":";;AAKA,gCAaC;AAlBD,6DAA0D;AAC1D,mEAA+D;AAI/D,SAAgB,UAAU,CAAC,QAAe,WAAW;IACnD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,CAAC,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC;QACpE,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC/D,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAE3D,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,CAAC,QAAQ,CAAC;YACf,MAAM;YACN,IAAI,EAAE,YAAY;YAClB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injection.decorators.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/injection.decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"injection.decorators.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/injection.decorators.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,SAAS,IAAI,iBAAiB,CAsB7C;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,iBAAiB,CAalE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,GAAG,iBAAiB,CAkBpE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAIzD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAkB3D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAI5C;AAED;;;GAGG;AACH,wBAAgB,IAAI,IAAI,iBAAiB,CAkBxC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,eAAe,CAiB/C;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,eAAe,CAiB5C"}
|
|
@@ -10,6 +10,7 @@ exports.Lazy = Lazy;
|
|
|
10
10
|
exports.PostConstruct = PostConstruct;
|
|
11
11
|
exports.PreDestroy = PreDestroy;
|
|
12
12
|
const metadata_keys_1 = require("../metadata/metadata-keys");
|
|
13
|
+
const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
13
14
|
/**
|
|
14
15
|
* @Autowired - Automatically inject dependencies by type
|
|
15
16
|
* Usage: @Autowired() private myService: MyService;
|
|
@@ -19,10 +20,17 @@ function Autowired() {
|
|
|
19
20
|
// Get the design type from TypeScript metadata
|
|
20
21
|
const type = Reflect.getMetadata("design:type", target, propertyKey);
|
|
21
22
|
if (!type || type === Object) {
|
|
22
|
-
|
|
23
|
-
`
|
|
23
|
+
console.warn(`ā ļø Could not determine type for ${target.constructor.name}.${String(propertyKey)}. ` +
|
|
24
|
+
`Ensure emitDecoratorMetadata is enabled in tsconfig.json`);
|
|
24
25
|
}
|
|
25
|
-
// Store
|
|
26
|
+
// Store metadata for property injection
|
|
27
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
28
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
29
|
+
type: "autowired",
|
|
30
|
+
key: propertyKey.toString(),
|
|
31
|
+
metadata: { type },
|
|
32
|
+
});
|
|
33
|
+
// Also store in Reflect metadata for backward compatibility
|
|
26
34
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.AUTOWIRED, type, target, propertyKey);
|
|
27
35
|
};
|
|
28
36
|
}
|
|
@@ -33,6 +41,14 @@ function Autowired() {
|
|
|
33
41
|
*/
|
|
34
42
|
function Inject(token) {
|
|
35
43
|
return (target, propertyKey) => {
|
|
44
|
+
// Store metadata for property injection
|
|
45
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
46
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
47
|
+
type: "inject",
|
|
48
|
+
key: propertyKey.toString(),
|
|
49
|
+
metadata: { token },
|
|
50
|
+
});
|
|
51
|
+
// Also store in Reflect metadata for backward compatibility
|
|
36
52
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.INJECT, token, target, propertyKey);
|
|
37
53
|
};
|
|
38
54
|
}
|
|
@@ -42,6 +58,14 @@ function Inject(token) {
|
|
|
42
58
|
*/
|
|
43
59
|
function InjectRepository(entity) {
|
|
44
60
|
return (target, propertyKey) => {
|
|
61
|
+
// Store metadata for property injection
|
|
62
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
63
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
64
|
+
type: "repository",
|
|
65
|
+
key: propertyKey.toString(),
|
|
66
|
+
metadata: { entity },
|
|
67
|
+
});
|
|
68
|
+
// Also store in Reflect metadata for backward compatibility
|
|
45
69
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.INJECT_REPOSITORY, entity, target, propertyKey);
|
|
46
70
|
};
|
|
47
71
|
}
|
|
@@ -61,6 +85,14 @@ function Qualifier(name) {
|
|
|
61
85
|
*/
|
|
62
86
|
function Value(expression) {
|
|
63
87
|
return (target, propertyKey) => {
|
|
88
|
+
// Store metadata for property injection
|
|
89
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
90
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
91
|
+
type: "value",
|
|
92
|
+
key: propertyKey.toString(),
|
|
93
|
+
metadata: { expression },
|
|
94
|
+
});
|
|
95
|
+
// Also store in Reflect metadata for backward compatibility
|
|
64
96
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.VALUE, expression, target, propertyKey);
|
|
65
97
|
};
|
|
66
98
|
}
|
|
@@ -79,24 +111,18 @@ function Optional() {
|
|
|
79
111
|
*/
|
|
80
112
|
function Lazy() {
|
|
81
113
|
return (target, propertyKey) => {
|
|
114
|
+
// Mark as lazy in metadata
|
|
82
115
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.LAZY, true, target, propertyKey);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
get() {
|
|
89
|
-
if (!resolved) {
|
|
90
|
-
const { DIContainer } = require("../container/di-container");
|
|
91
|
-
const container = DIContainer.getInstance();
|
|
92
|
-
cached = container.resolve(type);
|
|
93
|
-
resolved = true;
|
|
94
|
-
}
|
|
95
|
-
return cached;
|
|
96
|
-
},
|
|
97
|
-
enumerable: true,
|
|
98
|
-
configurable: true,
|
|
116
|
+
// Store metadata for property injection
|
|
117
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
118
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
119
|
+
type: "lazy",
|
|
120
|
+
key: propertyKey.toString(),
|
|
99
121
|
});
|
|
122
|
+
// Get the type for later resolution
|
|
123
|
+
const type = Reflect.getMetadata("design:type", target, propertyKey);
|
|
124
|
+
// This will be handled by the container during injection
|
|
125
|
+
// (not directly creating the getter here to avoid container dependency)
|
|
100
126
|
};
|
|
101
127
|
}
|
|
102
128
|
/**
|
|
@@ -105,6 +131,8 @@ function Lazy() {
|
|
|
105
131
|
*/
|
|
106
132
|
function PostConstruct() {
|
|
107
133
|
return (target, propertyKey, descriptor) => {
|
|
134
|
+
const className = target.constructor.name;
|
|
135
|
+
console.log(` šļø Registering @PostConstruct: ${className}.${String(propertyKey)}`);
|
|
108
136
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.POST_CONSTRUCT, propertyKey, target.constructor);
|
|
109
137
|
};
|
|
110
138
|
}
|
|
@@ -114,6 +142,8 @@ function PostConstruct() {
|
|
|
114
142
|
*/
|
|
115
143
|
function PreDestroy() {
|
|
116
144
|
return (target, propertyKey, descriptor) => {
|
|
145
|
+
const className = target.constructor.name;
|
|
146
|
+
console.log(` š§¹ Registering @PreDestroy: ${className}.${String(propertyKey)}`);
|
|
117
147
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.PRE_DESTROY, propertyKey, target.constructor);
|
|
118
148
|
};
|
|
119
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injection.decorators.js","sourceRoot":"","sources":["../../../src/core/decorators/injection.decorators.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"injection.decorators.js","sourceRoot":"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,OAAO,CACL,MAAW,EACX,WAA4B,EAC5B,UAA8B,EAC9B,EAAE;QACF,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QAC1C,OAAO,CAAC,GAAG,CACT,qCAAqC,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CACxE,CAAC;QAEF,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,cAAc,EAC5B,WAAW,EACX,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,UAAU;IACxB,OAAO,CACL,MAAW,EACX,WAA4B,EAC5B,UAA8B,EAC9B,EAAE;QACF,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QAC1C,OAAO,CAAC,GAAG,CACT,gCAAgC,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CACnE,CAAC;QAEF,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,WAAW,EACzB,WAAW,EACX,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"repository.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,cAAc,CAa3C"}
|
|
@@ -6,6 +6,7 @@ const metadata_keys_1 = require("../metadata/metadata-keys");
|
|
|
6
6
|
const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
7
7
|
function Repository() {
|
|
8
8
|
return (target) => {
|
|
9
|
+
console.log(`š¾ Registering Repository: ${target.name}`);
|
|
9
10
|
(0, injectable_decorator_1.Injectable)('singleton')(target);
|
|
10
11
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.REPOSITORY, true, target);
|
|
11
12
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":";;AAIA,
|
|
1
|
+
{"version":3,"file":"repository.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":";;AAIA,gCAaC;AAjBD,iEAAoD;AACpD,6DAA0D;AAC1D,mEAA+D;AAE/D,SAAgB,UAAU;IACxB,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,IAAA,iCAAU,EAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/D,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,CAAC,QAAQ,CAAC;YACf,MAAM;YACN,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"service.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,IAAI,cAAc,CAaxC"}
|
|
@@ -6,6 +6,7 @@ const metadata_keys_1 = require("../metadata/metadata-keys");
|
|
|
6
6
|
const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
7
7
|
function Service() {
|
|
8
8
|
return (target) => {
|
|
9
|
+
console.log(`āļø Registering Service: ${target.name}`);
|
|
9
10
|
(0, injectable_decorator_1.Injectable)('singleton')(target);
|
|
10
11
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.SERVICE, true, target);
|
|
11
12
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":";;AAIA,
|
|
1
|
+
{"version":3,"file":"service.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":";;AAIA,0BAaC;AAjBD,iEAAoD;AACpD,6DAA0D;AAC1D,mEAA+D;AAE/D,SAAgB,OAAO;IACrB,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,4BAA4B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACvD,IAAA,iCAAU,EAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE5D,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,CAAC,QAAQ,CAAC;YACf,MAAM;YACN,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -18,11 +18,17 @@ export interface ParamMetadata {
|
|
|
18
18
|
type: "body" | "param" | "query" | "header" | "req" | "res";
|
|
19
19
|
paramName?: string;
|
|
20
20
|
}
|
|
21
|
+
export interface PropertyInjectionMetadata {
|
|
22
|
+
type: "autowired" | "inject" | "repository" | "value" | "lazy";
|
|
23
|
+
key: string;
|
|
24
|
+
metadata?: any;
|
|
25
|
+
}
|
|
21
26
|
export declare class MetadataStorage {
|
|
22
27
|
private static instance;
|
|
23
28
|
private classes;
|
|
24
29
|
private methods;
|
|
25
30
|
private params;
|
|
31
|
+
private propertyInjections;
|
|
26
32
|
static getInstance(): MetadataStorage;
|
|
27
33
|
addClass(metadata: ClassMetadata): void;
|
|
28
34
|
getClass(target: any): ClassMetadata | undefined;
|
|
@@ -32,5 +38,10 @@ export declare class MetadataStorage {
|
|
|
32
38
|
getAllMethods(): MethodMetadata[];
|
|
33
39
|
addParam(metadata: ParamMetadata): void;
|
|
34
40
|
getParams(target: any, propertyKey: string): ParamMetadata[];
|
|
41
|
+
addPropertyInjection(target: any, propertyKey: string, injection: PropertyInjectionMetadata): void;
|
|
42
|
+
getPropertyInjections(target: any): {
|
|
43
|
+
propertyKey: string;
|
|
44
|
+
injections: PropertyInjectionMetadata[];
|
|
45
|
+
}[];
|
|
35
46
|
}
|
|
36
47
|
//# sourceMappingURL=metadata-storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-storage.d.ts","sourceRoot":"","sources":["../../../src/core/metadata/metadata-storage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EACA,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,oBAAoB,CAAC;IACzB,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,C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CAChB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkB;IACzC,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,OAAO,CAA0C;IACzD,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,kBAAkB,CACd;IAEZ,MAAM,CAAC,WAAW,IAAI,eAAe;IAOrC,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAIvC,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,aAAa,GAAG,SAAS;IAIhD,aAAa,IAAI,aAAa,EAAE;IAIhC,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAYzC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAKvE,aAAa,IAAI,cAAc,EAAE;IAIjC,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAOvC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,EAAE;IAQ5D,oBAAoB,CAClB,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,yBAAyB,GACnC,IAAI;IAgBP,qBAAqB,CACnB,MAAM,EAAE,GAAG,GACV;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,yBAAyB,EAAE,CAAA;KAAE,EAAE;CAgBtE"}
|
|
@@ -6,6 +6,7 @@ class MetadataStorage {
|
|
|
6
6
|
this.classes = new Map();
|
|
7
7
|
this.methods = new Map();
|
|
8
8
|
this.params = new Map();
|
|
9
|
+
this.propertyInjections = new Map();
|
|
9
10
|
}
|
|
10
11
|
static getInstance() {
|
|
11
12
|
if (!MetadataStorage.instance) {
|
|
@@ -48,6 +49,27 @@ class MetadataStorage {
|
|
|
48
49
|
const key = `${targetName}.${propertyKey}`;
|
|
49
50
|
return this.params.get(key) || [];
|
|
50
51
|
}
|
|
52
|
+
addPropertyInjection(target, propertyKey, injection) {
|
|
53
|
+
const className = target.name || target.constructor?.name;
|
|
54
|
+
const key = `${className}.${propertyKey}`;
|
|
55
|
+
if (!this.propertyInjections.has(key)) {
|
|
56
|
+
this.propertyInjections.set(key, []);
|
|
57
|
+
}
|
|
58
|
+
const injections = this.propertyInjections.get(key);
|
|
59
|
+
injections.push(injection);
|
|
60
|
+
console.log(` šÆ Registered property injection: ${className}.${propertyKey} [${injection.type}]`);
|
|
61
|
+
}
|
|
62
|
+
getPropertyInjections(target) {
|
|
63
|
+
const className = target.name || target.constructor?.name;
|
|
64
|
+
const result = [];
|
|
65
|
+
this.propertyInjections.forEach((injections, key) => {
|
|
66
|
+
if (key.startsWith(`${className}.`)) {
|
|
67
|
+
const propertyKey = key.split(".")[1];
|
|
68
|
+
result.push({ propertyKey, injections });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
51
73
|
}
|
|
52
74
|
exports.MetadataStorage = MetadataStorage;
|
|
53
75
|
//# sourceMappingURL=metadata-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-storage.js","sourceRoot":"","sources":["../../../src/core/metadata/metadata-storage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"metadata-storage.js","sourceRoot":"","sources":["../../../src/core/metadata/metadata-storage.ts"],"names":[],"mappings":";;;AAoCA,MAAa,eAAe;IAA5B;QAEU,YAAO,GAA4B,IAAI,GAAG,EAAE,CAAC;QAC7C,YAAO,GAAgC,IAAI,GAAG,EAAE,CAAC;QACjD,WAAM,GAAiC,IAAI,GAAG,EAAE,CAAC;QACjD,uBAAkB,GACxB,IAAI,GAAG,EAAE,CAAC;IA+Fd,CAAC;IA7FC,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;YAC9B,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE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AAqB,CACnB,MAAW;QAEX,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC;QAC1D,MAAM,MAAM,GAGN,EAAE,CAAC;QAET,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE;YAClD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArGD,0CAqGC"}
|
|
@@ -6,13 +6,7 @@ export declare class FragmentWebApplication {
|
|
|
6
6
|
constructor();
|
|
7
7
|
private setupMiddleware;
|
|
8
8
|
bootstrap(appClass: any): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Detects environment and scans appropriate files
|
|
11
|
-
*/
|
|
12
9
|
private scanComponents;
|
|
13
|
-
/**
|
|
14
|
-
* Detects if we're running TypeScript directly (ts-node or similar)
|
|
15
|
-
*/
|
|
16
10
|
private isRunningTypeScript;
|
|
17
11
|
private discoverAndRegisterComponents;
|
|
18
12
|
private getTypeIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/web/application.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAmC,MAAM,SAAS,CAAC;AAY5E,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,eAAe,CAAkB;;IAUzC,OAAO,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/web/application.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAmC,MAAM,SAAS,CAAC;AAY5E,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,eAAe,CAAkB;;IAUzC,OAAO,CAAC,eAAe;IASjB,SAAS,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YAwC/B,cAAc;IA0B5B,OAAO,CAAC,mBAAmB;IAgC3B,OAAO,CAAC,6BAA6B;IA2DrC,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,cAAc;IA2CtB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,cAAc;IA6EtB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAcpB,aAAa,IAAI,OAAO;CAGzB"}
|
package/dist/web/application.js
CHANGED
|
@@ -50,13 +50,14 @@ const component_scanner_1 = require("../core/scanner/component-scanner");
|
|
|
50
50
|
const typeorm_module_1 = require("../typeorm/typeorm-module");
|
|
51
51
|
class FragmentWebApplication {
|
|
52
52
|
constructor() {
|
|
53
|
+
console.log("š± Initializing Fragment Framework");
|
|
53
54
|
this.app = (0, express_1.default)();
|
|
54
55
|
this.container = di_container_1.DIContainer.getInstance();
|
|
55
56
|
this.metadataStorage = metadata_storage_1.MetadataStorage.getInstance();
|
|
56
57
|
this.setupMiddleware();
|
|
57
|
-
this;
|
|
58
58
|
}
|
|
59
59
|
setupMiddleware() {
|
|
60
|
+
console.log("āļø Setting up middleware");
|
|
60
61
|
this.app.use((0, helmet_1.default)());
|
|
61
62
|
this.app.use((0, cors_1.default)());
|
|
62
63
|
this.app.use((0, compression_1.default)());
|
|
@@ -64,12 +65,21 @@ class FragmentWebApplication {
|
|
|
64
65
|
this.app.use(express_1.default.urlencoded({ extended: true }));
|
|
65
66
|
}
|
|
66
67
|
async bootstrap(appClass) {
|
|
67
|
-
|
|
68
|
+
console.log("\nš Bootstrapping application");
|
|
69
|
+
try {
|
|
70
|
+
await typeorm_module_1.TypeORMModule.initialize();
|
|
71
|
+
console.log("ā
TypeORM initialized successfully");
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error("ā Failed to initialize TypeORM:", error);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
68
77
|
const appMetadata = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.APPLICATION, appClass);
|
|
78
|
+
console.log(`šÆ Application metadata:`, appMetadata);
|
|
69
79
|
// CRITICAL: Scan and load all component files first
|
|
70
80
|
// This triggers decorator execution
|
|
71
81
|
if (appMetadata?.autoScan !== false) {
|
|
72
|
-
console.log("š Scanning for components...");
|
|
82
|
+
console.log("\nš Scanning for components...");
|
|
73
83
|
await this.scanComponents();
|
|
74
84
|
}
|
|
75
85
|
// Now metadata storage will be populated
|
|
@@ -79,35 +89,34 @@ class FragmentWebApplication {
|
|
|
79
89
|
const host = appMetadata?.host || "0.0.0.0";
|
|
80
90
|
this.app.use(this.errorHandler.bind(this));
|
|
81
91
|
this.app.listen(port, host, () => {
|
|
82
|
-
console.log(
|
|
92
|
+
console.log(`\n⨠Fragment application running on http://${host}:${port}`);
|
|
93
|
+
console.log("========================================\n");
|
|
83
94
|
});
|
|
84
95
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Detects environment and scans appropriate files
|
|
87
|
-
*/
|
|
88
96
|
async scanComponents() {
|
|
89
97
|
const cwd = process.cwd();
|
|
90
98
|
const distExists = fs.existsSync(path.join(cwd, "dist"));
|
|
91
99
|
const srcExists = fs.existsSync(path.join(cwd, "src"));
|
|
100
|
+
console.log(`š Current working directory: ${cwd}`);
|
|
101
|
+
console.log(`š dist/ exists: ${distExists}`);
|
|
102
|
+
console.log(`š src/ exists: ${srcExists}`);
|
|
92
103
|
// Determine if we're running TypeScript directly (dev) or compiled JS (prod)
|
|
93
104
|
const isDevMode = this.isRunningTypeScript();
|
|
105
|
+
console.log(`š» Running in ${isDevMode ? 'development' : 'production'} mode`);
|
|
94
106
|
if (isDevMode && srcExists) {
|
|
95
107
|
// Development mode: scan TypeScript source files
|
|
96
|
-
console.log("
|
|
108
|
+
console.log(" š Development mode: scanning TypeScript files");
|
|
97
109
|
await component_scanner_1.ComponentScanner.scanSource();
|
|
98
110
|
}
|
|
99
111
|
else if (distExists) {
|
|
100
112
|
// Production mode: scan compiled JavaScript files
|
|
101
|
-
console.log("
|
|
113
|
+
console.log(" š¦ Production mode: scanning compiled files");
|
|
102
114
|
await component_scanner_1.ComponentScanner.scan();
|
|
103
115
|
}
|
|
104
116
|
else {
|
|
105
|
-
console.warn("
|
|
117
|
+
console.warn(" ā ļø Warning: No src/ or dist/ directory found");
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Detects if we're running TypeScript directly (ts-node or similar)
|
|
110
|
-
*/
|
|
111
120
|
isRunningTypeScript() {
|
|
112
121
|
// Check if ts-node is in require.extensions
|
|
113
122
|
if (require.extensions[".ts"]) {
|
|
@@ -144,7 +153,10 @@ class FragmentWebApplication {
|
|
|
144
153
|
}, {});
|
|
145
154
|
Object.entries(grouped).forEach(([type, items]) => {
|
|
146
155
|
const icon = this.getTypeIcon(type);
|
|
147
|
-
console.log(`
|
|
156
|
+
console.log(` ${icon} ${items.length} ${type}(s)`);
|
|
157
|
+
items.forEach(item => {
|
|
158
|
+
console.log(` ⢠${item.target.name}${item.path ? ` (${item.path})` : ''}`);
|
|
159
|
+
});
|
|
148
160
|
});
|
|
149
161
|
let registered = 0;
|
|
150
162
|
let skipped = 0;
|
|
@@ -154,19 +166,29 @@ class FragmentWebApplication {
|
|
|
154
166
|
if (!this.container.has(metadata.target)) {
|
|
155
167
|
this.container.register(metadata.target);
|
|
156
168
|
registered++;
|
|
157
|
-
console.log(`
|
|
169
|
+
console.log(` ā Registered: ${metadata.target.name}`);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
console.log(` ā Already registered: ${metadata.target.name}`);
|
|
158
173
|
}
|
|
159
174
|
}
|
|
160
175
|
else {
|
|
161
176
|
skipped++;
|
|
162
|
-
console.log(`
|
|
177
|
+
console.log(` ā Skipped: ${metadata.target.name} (conditional check failed)`);
|
|
163
178
|
}
|
|
164
179
|
});
|
|
165
|
-
console.log(`\n
|
|
180
|
+
console.log(`\nā Registered ${registered} component(s)`);
|
|
166
181
|
if (skipped > 0) {
|
|
167
|
-
console.log(
|
|
182
|
+
console.log(`ā Skipped ${skipped} component(s) (conditions not met)`);
|
|
168
183
|
}
|
|
169
|
-
|
|
184
|
+
// Pre-resolve all singleton components to ensure dependencies are injected
|
|
185
|
+
console.log("\nš§ Initializing components");
|
|
186
|
+
classes.forEach(metadata => {
|
|
187
|
+
if (this.shouldRegister(metadata.target)) {
|
|
188
|
+
const instance = this.container.resolve(metadata.target);
|
|
189
|
+
console.log(` ā Initialized: ${metadata.target.name}`);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
170
192
|
}
|
|
171
193
|
getTypeIcon(type) {
|
|
172
194
|
const icons = {
|
|
@@ -181,20 +203,25 @@ class FragmentWebApplication {
|
|
|
181
203
|
shouldRegister(target) {
|
|
182
204
|
const conditionalClass = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.CONDITIONAL_ON_CLASS, target);
|
|
183
205
|
if (conditionalClass && !this.isClassAvailable(conditionalClass)) {
|
|
206
|
+
console.log(` š« Conditional check failed for ${target.name}: Class not available`);
|
|
184
207
|
return false;
|
|
185
208
|
}
|
|
186
209
|
const conditionalMissingBean = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.CONDITIONAL_ON_MISSING_BEAN, target);
|
|
187
210
|
if (conditionalMissingBean && this.container.has(conditionalMissingBean)) {
|
|
211
|
+
console.log(` š« Conditional check failed for ${target.name}: Bean already exists`);
|
|
188
212
|
return false;
|
|
189
213
|
}
|
|
190
214
|
const conditionalProperty = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.CONDITIONAL_ON_PROPERTY, target);
|
|
191
215
|
if (conditionalProperty) {
|
|
192
216
|
const value = process.env[conditionalProperty.key];
|
|
193
|
-
if (conditionalProperty.expectedValue !== undefined
|
|
194
|
-
value !== conditionalProperty.expectedValue) {
|
|
195
|
-
|
|
217
|
+
if (conditionalProperty.expectedValue !== undefined) {
|
|
218
|
+
if (value !== conditionalProperty.expectedValue) {
|
|
219
|
+
console.log(` š« Conditional check failed for ${target.name}: Expected ${conditionalProperty.expectedValue}, got ${value}`);
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
196
222
|
}
|
|
197
|
-
if (!value) {
|
|
223
|
+
else if (!value) {
|
|
224
|
+
console.log(` š« Conditional check failed for ${target.name}: Property not set`);
|
|
198
225
|
return false;
|
|
199
226
|
}
|
|
200
227
|
}
|
|
@@ -213,44 +240,53 @@ class FragmentWebApplication {
|
|
|
213
240
|
.getAllClasses()
|
|
214
241
|
.filter((c) => c.type === "controller");
|
|
215
242
|
if (controllers.length === 0) {
|
|
216
|
-
console.log("š£ļø
|
|
243
|
+
console.log("\nš£ļø No routes to register");
|
|
217
244
|
return;
|
|
218
245
|
}
|
|
219
246
|
let totalRoutes = 0;
|
|
220
|
-
console.log(
|
|
247
|
+
console.log(`\nš£ļø Registering routes...`);
|
|
221
248
|
controllers.forEach((controllerMetadata) => {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
249
|
+
try {
|
|
250
|
+
console.log(`\nš Controller: ${controllerMetadata.target.name}`);
|
|
251
|
+
console.log(` Base path: ${controllerMetadata.path || '/'}`);
|
|
252
|
+
const controller = this.container.resolve(controllerMetadata.target);
|
|
253
|
+
const basePath = controllerMetadata.path || "";
|
|
254
|
+
const methods = this.metadataStorage
|
|
255
|
+
.getAllMethods()
|
|
256
|
+
.filter((m) => m.target === controllerMetadata.target);
|
|
257
|
+
if (methods.length === 0) {
|
|
258
|
+
console.log(` ā ļø No routes defined for this controller`);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
230
261
|
methods.forEach((methodMetadata) => {
|
|
231
262
|
const fullPath = this.normalizePath(basePath + methodMetadata.path);
|
|
232
263
|
const httpMethod = methodMetadata.method.toLowerCase();
|
|
233
264
|
const methodColor = this.getMethodColor(httpMethod);
|
|
234
265
|
const methodIcon = this.getMethodIcon(httpMethod);
|
|
235
|
-
console.log(`
|
|
266
|
+
console.log(` ${methodIcon} ${methodColor}${httpMethod.toUpperCase().padEnd(7)}\x1b[0m ${fullPath}`);
|
|
236
267
|
totalRoutes++;
|
|
237
268
|
this.app[httpMethod](fullPath, async (req, res, next) => {
|
|
238
269
|
try {
|
|
239
270
|
const args = this.resolveMethodParameters(methodMetadata, req, res);
|
|
271
|
+
console.log(`\nš Handling ${httpMethod.toUpperCase()} ${fullPath}`);
|
|
272
|
+
// console.log(` Parameters:`, args);
|
|
240
273
|
const result = await controller[methodMetadata.propertyKey](...args);
|
|
241
274
|
if (!res.headersSent) {
|
|
242
275
|
res.json(result);
|
|
243
276
|
}
|
|
244
277
|
}
|
|
245
278
|
catch (error) {
|
|
279
|
+
console.error(`ā Error handling route ${fullPath}:`, error);
|
|
246
280
|
next(error);
|
|
247
281
|
}
|
|
248
282
|
});
|
|
249
283
|
});
|
|
250
|
-
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
console.error(`ā Failed to register controller ${controllerMetadata.target.name}:`, error);
|
|
251
287
|
}
|
|
252
288
|
});
|
|
253
|
-
console.log(
|
|
289
|
+
console.log(`\nā Registered ${totalRoutes} route(s)`);
|
|
254
290
|
}
|
|
255
291
|
getMethodColor(method) {
|
|
256
292
|
const colors = {
|
|
@@ -273,7 +309,7 @@ class FragmentWebApplication {
|
|
|
273
309
|
return icons[method] || "ā¢";
|
|
274
310
|
}
|
|
275
311
|
resolveMethodParameters(methodMetadata, req, res) {
|
|
276
|
-
const params = methodMetadata.paramMetadata.sort((a, b) => a.index - b.index);
|
|
312
|
+
const params = [...methodMetadata.paramMetadata].sort((a, b) => a.index - b.index);
|
|
277
313
|
return params.map((param) => {
|
|
278
314
|
switch (param.type) {
|
|
279
315
|
case "body":
|
|
@@ -299,10 +335,11 @@ class FragmentWebApplication {
|
|
|
299
335
|
return "/" + path.split("/").filter(Boolean).join("/");
|
|
300
336
|
}
|
|
301
337
|
errorHandler(err, req, res, next) {
|
|
302
|
-
console.error(err
|
|
338
|
+
console.error(`\nā Global error handler:`, err);
|
|
303
339
|
res.status(500).json({
|
|
304
340
|
error: "Internal Server Error",
|
|
305
341
|
message: err.message,
|
|
342
|
+
timestamp: new Date().toISOString(),
|
|
306
343
|
});
|
|
307
344
|
}
|
|
308
345
|
getExpressApp() {
|