milkio 1.0.0-alpha.31 → 1.0.0-alpha.32
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/package.json +1 -1
- package/world/index.ts +10 -3
package/package.json
CHANGED
package/world/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type MilkioInit = {
|
|
|
17
17
|
executeId?: (request: Request) => string | Promise<string>;
|
|
18
18
|
onLoggerSubmitting?: LoggerSubmittingHandler;
|
|
19
19
|
onLoggerInserting?: LoggerInsertingHandler;
|
|
20
|
+
bootstraps?: Array<(world: MilkioWorld<any>) => Promise<void>>;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export type MilkioRuntimeInit<T extends MilkioInit> = Mixin<
|
|
@@ -58,7 +59,7 @@ export const createWorld = async <MilkioOptions extends MilkioInit>(generated: G
|
|
|
58
59
|
const getConfig = (namespace: keyof $types["generated"]["configSchema"], env: Record<any, any>, envMode: string) => __getConfig(generated, env, envMode, namespace);
|
|
59
60
|
|
|
60
61
|
// Initialize the app
|
|
61
|
-
const
|
|
62
|
+
const world = {
|
|
62
63
|
_: _,
|
|
63
64
|
// event manager
|
|
64
65
|
on: eventManager.on,
|
|
@@ -72,9 +73,15 @@ export const createWorld = async <MilkioOptions extends MilkioInit>(generated: G
|
|
|
72
73
|
getConfig,
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
runtime.app =
|
|
76
|
+
runtime.app = world;
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
if (Array.isArray(options.bootstraps)) {
|
|
79
|
+
for (const bootstrap of options.bootstraps) {
|
|
80
|
+
await bootstrap(world as MilkioWorld<MilkioOptions>);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return world as MilkioWorld<MilkioOptions>;
|
|
78
85
|
};
|
|
79
86
|
|
|
80
87
|
export type MilkioWorld<MilkioOptions extends MilkioInit = MilkioInit> = {
|