@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
|
@@ -89,7 +89,7 @@ export declare abstract class PlatformBuilder<App = TsED.Application, Router = T
|
|
|
89
89
|
stop(): Promise<void>;
|
|
90
90
|
ready(): Promise<void>;
|
|
91
91
|
callHook(hook: string, ...args: any[]): Promise<void>;
|
|
92
|
-
loadStatics(): Promise<void>;
|
|
92
|
+
loadStatics(hook: string): Promise<void>;
|
|
93
93
|
useProvider(token: Type<any>, settings?: Partial<IProvider>): this;
|
|
94
94
|
protected importProviders(): Promise<void>;
|
|
95
95
|
/**
|
package/lib/index.js
CHANGED
|
@@ -2722,6 +2722,26 @@ function createContext(injector) {
|
|
|
2722
2722
|
};
|
|
2723
2723
|
}
|
|
2724
2724
|
|
|
2725
|
+
function mapOptions$1(options) {
|
|
2726
|
+
const opts = typeof options === "string" ? {
|
|
2727
|
+
root: options,
|
|
2728
|
+
hook: "$afterRoutesInit"
|
|
2729
|
+
} : options;
|
|
2730
|
+
return opts;
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
function getStaticsOptions(statics) {
|
|
2734
|
+
return Object.entries(statics || {}).reduce((statics, [path, items]) => {
|
|
2735
|
+
[].concat(items).forEach(options => {
|
|
2736
|
+
statics.push({
|
|
2737
|
+
path,
|
|
2738
|
+
options: mapOptions$1(options)
|
|
2739
|
+
});
|
|
2740
|
+
});
|
|
2741
|
+
return statics;
|
|
2742
|
+
}, []);
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2725
2745
|
const SKIP_HOOKS = ["$beforeInit", "$afterInit", "$onInit", "$onMountingMiddlewares"];
|
|
2726
2746
|
const {
|
|
2727
2747
|
bind,
|
|
@@ -2930,21 +2950,16 @@ class PlatformBuilder {
|
|
|
2930
2950
|
}
|
|
2931
2951
|
}
|
|
2932
2952
|
|
|
2933
|
-
async loadStatics() {
|
|
2934
|
-
const
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
} : options;
|
|
2944
|
-
this.platform.app.statics(path, opts);
|
|
2945
|
-
});
|
|
2946
|
-
});
|
|
2947
|
-
}
|
|
2953
|
+
async loadStatics(hook) {
|
|
2954
|
+
const statics = this.settings.get("statics");
|
|
2955
|
+
getStaticsOptions(statics).forEach(({
|
|
2956
|
+
path,
|
|
2957
|
+
options
|
|
2958
|
+
}) => {
|
|
2959
|
+
if (options.hook === hook) {
|
|
2960
|
+
this.platform.app.statics(path, options);
|
|
2961
|
+
}
|
|
2962
|
+
});
|
|
2948
2963
|
}
|
|
2949
2964
|
|
|
2950
2965
|
useProvider(token, settings) {
|
|
@@ -3041,10 +3056,11 @@ class PlatformBuilder {
|
|
|
3041
3056
|
}
|
|
3042
3057
|
|
|
3043
3058
|
this.log("Load routes");
|
|
3059
|
+
await this.loadStatics("$beforeRoutesInit");
|
|
3044
3060
|
await this.callHook("$beforeRoutesInit");
|
|
3045
3061
|
await this.callHook("$$loadRoutes");
|
|
3046
3062
|
await this.callHook("$onRoutesInit");
|
|
3047
|
-
await this.loadStatics();
|
|
3063
|
+
await this.loadStatics("$afterRoutesInit");
|
|
3048
3064
|
await this.callHook("$afterRoutesInit");
|
|
3049
3065
|
}
|
|
3050
3066
|
|