@spider-mesh/core 1.0.148 → 1.0.150
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/build/src/decorators/BeforeMicroserviceOnline.d.ts +2 -4
- package/build/src/decorators/BeforeMicroserviceOnline.js +6 -10
- package/build/src/decorators/BeforeMicroserviceOnline.js.map +1 -1
- package/build/src/decorators/Microservice.js +3 -2
- package/build/src/decorators/Microservice.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
1
2
|
import { SpiderMesh } from "../SpiderMesh.js";
|
|
2
3
|
export declare const key: unique symbol;
|
|
3
|
-
export type BeforeMicroserviceOnlineMetadata = {
|
|
4
|
-
method: string;
|
|
5
|
-
};
|
|
6
4
|
export declare const BeforeMicroserviceOnline: () => <T>(target: Object, method: string | symbol, descriptor: TypedPropertyDescriptor<T | ((sm?: SpiderMesh) => Promise<void>)>) => void;
|
|
7
|
-
export declare const listBeforeMicroserviceOnlineMethods: (target: any) =>
|
|
5
|
+
export declare const listBeforeMicroserviceOnlineMethods: (target: any) => string[];
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
1
2
|
export const key = Symbol.for('BeforeMicroserviceOnline');
|
|
2
3
|
export const BeforeMicroserviceOnline = () => (target, method, descriptor) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (let f = target; f != null; f = Object.getPrototypeOf(f)) {
|
|
8
|
-
for (const method of Object.getOwnPropertyNames(f)) {
|
|
9
|
-
f[method]?.[key] && methods.push(f[method]?.[key]);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return methods;
|
|
4
|
+
Reflect.defineMetadata(key, [
|
|
5
|
+
...Reflect.getMetadata(key, target) || [],
|
|
6
|
+
method
|
|
7
|
+
], target);
|
|
13
8
|
};
|
|
9
|
+
export const listBeforeMicroserviceOnlineMethods = (target) => Reflect.getMetadata(key, target);
|
|
14
10
|
//# sourceMappingURL=BeforeMicroserviceOnline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeforeMicroserviceOnline.js","sourceRoot":"","sources":["../../../src/decorators/BeforeMicroserviceOnline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BeforeMicroserviceOnline.js","sourceRoot":"","sources":["../../../src/decorators/BeforeMicroserviceOnline.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAAC,CAC1C,MAAc,EACd,MAAuB,EACvB,UAA6E,EAC/E,EAAE;IACA,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE;QACxB,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE;QACzC,MAAM;KACT,EAAE,MAAM,CAAC,CAAA;AACd,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,MAAW,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAa,CAAA"}
|
|
@@ -7,8 +7,9 @@ export const Microservice = (namespace = NAMEPSACE, metadata = {}) => {
|
|
|
7
7
|
class C extends target {
|
|
8
8
|
constructor(...args) {
|
|
9
9
|
super(...args);
|
|
10
|
-
from(listBeforeMicroserviceOnlineMethods(this)).pipe(mergeMap(async (
|
|
11
|
-
|
|
10
|
+
from(listBeforeMicroserviceOnlineMethods(this)).pipe(mergeMap(async (method) => {
|
|
11
|
+
const fn = this[method];
|
|
12
|
+
typeof fn == 'function' && await fn();
|
|
12
13
|
}, 1), toArray(), tap(() => $services.next({
|
|
13
14
|
instance: this,
|
|
14
15
|
namespace,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Microservice.js","sourceRoot":"","sources":["../../../src/decorators/Microservice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,mCAAmC,EAAE,MAAM,+BAA+B,CAAA;AAEnF,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,aAAa,EAAmE,CAAA;AAG7G,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,YAAoB,SAAS,EAAE,WAA4B,EAAE,EAAE,EAAE;IAC1F,OAAO,CACH,CAAC,MAAmC,EAAE,EAAE;QACpC,MAAM,CAAE,SAAQ,MAAM;YAClB,YAAY,GAAG,IAAW;gBACtB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;gBACd,IAAI,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAChD,QAAQ,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"Microservice.js","sourceRoot":"","sources":["../../../src/decorators/Microservice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,mCAAmC,EAAE,MAAM,+BAA+B,CAAA;AAEnF,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,aAAa,EAAmE,CAAA;AAG7G,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,YAAoB,SAAS,EAAE,WAA4B,EAAE,EAAE,EAAE;IAC1F,OAAO,CACH,CAAC,MAAmC,EAAE,EAAE;QACpC,MAAM,CAAE,SAAQ,MAAM;YAClB,YAAY,GAAG,IAAW;gBACtB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;gBACd,IAAI,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAChD,QAAQ,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;oBACpB,MAAM,EAAE,GAAI,IAAY,CAAC,MAAM,CAAC,CAAA;oBAChC,OAAO,EAAE,IAAI,UAAU,IAAI,MAAM,EAAE,EAAE,CAAA;gBACzC,CAAC,EAAE,CAAC,CAAC,EACL,OAAO,EAAE,EACT,GAAG,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;oBACrB,QAAQ,EAAE,IAAI;oBACd,SAAS;oBACT,QAAQ;iBACX,CAAC,CAAC,CACN,CAAC,SAAS,EAAE,CAAA;YAEjB,CAAC;SACJ;QACD,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QACxD,OAAO,CAAQ,CAAA;IACnB,CAAC,CAGG,CAAA;AACZ,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spider-mesh/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.150",
|
|
5
5
|
"description": "Lightweight microservice framework for typescript, auto discovery, load-balancing, fault-torrent, multiple transporters",
|
|
6
6
|
"main": "./build/src/index.js",
|
|
7
7
|
"types": "./build/src/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/node": "^18.16.0",
|
|
18
|
+
"@types/reflect-metadata": "^0.1.0",
|
|
18
19
|
"@types/uuid": "^10.0.0",
|
|
19
20
|
"ts-node": "^10.9.1",
|
|
20
21
|
"typescript": "^5.0.4"
|