milkio 1.0.0-alpha.30 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/world/index.ts +10 -3
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "1.0.0-alpha.30",
5
+ "version": "1.0.0-alpha.32",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },
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 app = {
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 = app;
76
+ runtime.app = world;
76
77
 
77
- return app as MilkioWorld<MilkioOptions>;
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> = {