@tsed/common 6.73.8 → 6.75.0
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/lib/builder/PlatformBuilder.d.ts +1 -1
- package/lib/config/interfaces/PlatformStaticsSettings.d.ts +1 -0
- package/lib/index.js +32 -16
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +32 -16
- package/lib/index.modern.js.map +1 -1
- package/lib/utils/getStaticsOptions.d.ts +5 -0
- package/package.json +15 -15
package/lib/index.modern.js
CHANGED
|
@@ -2713,6 +2713,26 @@ function createContext(injector) {
|
|
|
2713
2713
|
};
|
|
2714
2714
|
}
|
|
2715
2715
|
|
|
2716
|
+
function mapOptions$1(options) {
|
|
2717
|
+
const opts = typeof options === "string" ? {
|
|
2718
|
+
root: options,
|
|
2719
|
+
hook: "$afterRoutesInit"
|
|
2720
|
+
} : options;
|
|
2721
|
+
return opts;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
function getStaticsOptions(statics) {
|
|
2725
|
+
return Object.entries(statics || {}).reduce((statics, [path, items]) => {
|
|
2726
|
+
[].concat(items).forEach(options => {
|
|
2727
|
+
statics.push({
|
|
2728
|
+
path,
|
|
2729
|
+
options: mapOptions$1(options)
|
|
2730
|
+
});
|
|
2731
|
+
});
|
|
2732
|
+
return statics;
|
|
2733
|
+
}, []);
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2716
2736
|
const SKIP_HOOKS = ["$beforeInit", "$afterInit", "$onInit", "$onMountingMiddlewares"];
|
|
2717
2737
|
const {
|
|
2718
2738
|
bind,
|
|
@@ -2921,21 +2941,16 @@ class PlatformBuilder {
|
|
|
2921
2941
|
}
|
|
2922
2942
|
}
|
|
2923
2943
|
|
|
2924
|
-
async loadStatics() {
|
|
2925
|
-
const
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
} : options;
|
|
2935
|
-
this.platform.app.statics(path, opts);
|
|
2936
|
-
});
|
|
2937
|
-
});
|
|
2938
|
-
}
|
|
2944
|
+
async loadStatics(hook) {
|
|
2945
|
+
const statics = this.settings.get("statics");
|
|
2946
|
+
getStaticsOptions(statics).forEach(({
|
|
2947
|
+
path,
|
|
2948
|
+
options
|
|
2949
|
+
}) => {
|
|
2950
|
+
if (options.hook === hook) {
|
|
2951
|
+
this.platform.app.statics(path, options);
|
|
2952
|
+
}
|
|
2953
|
+
});
|
|
2939
2954
|
}
|
|
2940
2955
|
|
|
2941
2956
|
useProvider(token, settings) {
|
|
@@ -3032,10 +3047,11 @@ class PlatformBuilder {
|
|
|
3032
3047
|
}
|
|
3033
3048
|
|
|
3034
3049
|
this.log("Load routes");
|
|
3050
|
+
await this.loadStatics("$beforeRoutesInit");
|
|
3035
3051
|
await this.callHook("$beforeRoutesInit");
|
|
3036
3052
|
await this.callHook("$$loadRoutes");
|
|
3037
3053
|
await this.callHook("$onRoutesInit");
|
|
3038
|
-
await this.loadStatics();
|
|
3054
|
+
await this.loadStatics("$afterRoutesInit");
|
|
3039
3055
|
await this.callHook("$afterRoutesInit");
|
|
3040
3056
|
}
|
|
3041
3057
|
|