@zenofolio/hyper-decor 1.0.48 → 1.0.49
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.
|
@@ -24,6 +24,7 @@ const middleware_transform_1 = __importDefault(require("../transform/middleware.
|
|
|
24
24
|
const tsyringe_1 = require("tsyringe");
|
|
25
25
|
const path_util_1 = require("../utils/path.util");
|
|
26
26
|
const imports_helper_1 = require("./imports.helper");
|
|
27
|
+
const service_store_1 = require("../stores/service.store");
|
|
27
28
|
const if_router = (current) => {
|
|
28
29
|
if (!current || !((current === null || current === void 0 ? void 0 : current.prototype) instanceof hyper_express_1.Router))
|
|
29
30
|
return new hyper_express_1.Router();
|
|
@@ -108,6 +109,16 @@ function prepareApplication(options, Target, app, log) {
|
|
|
108
109
|
routers.forEach(({ router, path }) => {
|
|
109
110
|
app.use((0, path_util_1.join)(prefix, path), router);
|
|
110
111
|
});
|
|
112
|
+
{
|
|
113
|
+
// initialize servies stored
|
|
114
|
+
for (const service of service_store_1.serviceStore) {
|
|
115
|
+
const instance = tsyringe_1.container.resolve(service);
|
|
116
|
+
if (instance.onInit)
|
|
117
|
+
yield instance.onInit();
|
|
118
|
+
}
|
|
119
|
+
// clean up the service store
|
|
120
|
+
service_store_1.serviceStore.clear();
|
|
121
|
+
}
|
|
111
122
|
});
|
|
112
123
|
}
|
|
113
124
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const serviceStore: Set<any>;
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Service = void 0;
|
|
4
4
|
const tsyringe_1 = require("tsyringe");
|
|
5
|
-
const
|
|
5
|
+
const service_store_1 = require("../__internals/stores/service.store");
|
|
6
|
+
const Service = () => {
|
|
6
7
|
return (target) => {
|
|
8
|
+
if (!service_store_1.serviceStore.has(target)) {
|
|
9
|
+
service_store_1.serviceStore.add(target);
|
|
10
|
+
}
|
|
7
11
|
const instance = tsyringe_1.container.resolve(target);
|
|
8
|
-
if (
|
|
12
|
+
if (!tsyringe_1.container.isRegistered(target)) {
|
|
9
13
|
tsyringe_1.container.registerInstance(target, instance);
|
|
10
14
|
}
|
|
11
15
|
return function (...args) {
|