@di-framework/di-framework 0.0.0-prerelease.309 → 0.0.0-prerelease.310

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.
@@ -102,6 +102,18 @@ export declare function Container(options?: {
102
102
  }): <T extends {
103
103
  new (...args: any[]): {};
104
104
  }>(constructor: T) => T;
105
+ /**
106
+ * Eagerly resolves a class once at definition time.
107
+ *
108
+ * Useful for startup-only classes (e.g. HTTP controllers) whose constructors
109
+ * register routes or side effects and should run before handling requests.
110
+ */
111
+ export declare function Bootstrap(options?: {
112
+ singleton?: boolean;
113
+ container?: DIContainer;
114
+ }): <T extends {
115
+ new (...args: any[]): {};
116
+ }>(constructor: T) => T;
105
117
  /**
106
118
  * Marks a constructor parameter or property for dependency injection
107
119
  *
@@ -125,6 +125,25 @@ export function Container(options = {}) {
125
125
  return constructor;
126
126
  };
127
127
  }
128
+ /**
129
+ * Eagerly resolves a class once at definition time.
130
+ *
131
+ * Useful for startup-only classes (e.g. HTTP controllers) whose constructors
132
+ * register routes or side effects and should run before handling requests.
133
+ */
134
+ export function Bootstrap(options = {}) {
135
+ return function (constructor) {
136
+ const container = options.container ?? useContainer();
137
+ // Allow bootstrap to be used with or without @Container().
138
+ if (!container.has(constructor)) {
139
+ const singleton = options.singleton ?? true;
140
+ defineMetadata(INJECTABLE_METADATA_KEY, true, constructor);
141
+ container.register(constructor, { singleton });
142
+ }
143
+ container.resolve(constructor);
144
+ return constructor;
145
+ };
146
+ }
128
147
  /**
129
148
  * Marks a constructor parameter or property for dependency injection
130
149
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@di-framework/di-framework",
3
- "version": "0.0.0-prerelease.309",
3
+ "version": "0.0.0-prerelease.310",
4
4
  "description": "Lightweight, zero-dependency TypeScript Dependency Injection framework using decorators. Works seamlessly with SWC and TypeScript's native decorator support.",
5
5
  "main": "./dist/container.js",
6
6
  "types": "./dist/container.d.ts",