@moostjs/event-http 0.6.35 → 0.6.36

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/dist/index.cjs CHANGED
@@ -616,6 +616,19 @@ const LOGGER_TITLE = "moost-http";
616
616
  onInit(moost$1) {
617
617
  this.moost = moost$1;
618
618
  }
619
+ /**
620
+ * Called by `Moost.dispose()` before any `@MoostDispose` hook runs: stops the
621
+ * HTTP server this adapter started through {@link MoostHttp.listen}, so
622
+ * shutdown drains in-flight requests before singletons release what they own.
623
+ *
624
+ * A no-op when no server is listening — the adapter was used as a middleware
625
+ * (`getServerCb()`), `listen()` was never called (or failed), or the server is
626
+ * already closed. Guarding on the live server avoids wooks' `close()`
627
+ * never-settling (no server) and Node's `ERR_SERVER_NOT_RUNNING` (closed).
628
+ */ async onDispose() {
629
+ if (!this.httpApp.getServer()?.listening) return;
630
+ await this.httpApp.close();
631
+ }
619
632
  getProvideRegistry() {
620
633
  return (0, _prostojs_infact.createProvideRegistry)([_wooksjs_event_http.WooksHttp, () => this.getHttpApp()], ["WooksHttp", () => this.getHttpApp()], [http.Server, () => this.getHttpApp().getServer()], [https.Server, () => this.getHttpApp().getServer()]);
621
634
  }
@@ -674,7 +687,7 @@ const LOGGER_TITLE = "moost-http";
674
687
  image: "https://moost.org/moost-full-logo.svg",
675
688
  link: "https://moost.org/",
676
689
  poweredBy: "moostjs",
677
- version: "0.6.35"
690
+ version: "0.6.36"
678
691
  });
679
692
  if (httpApp && httpApp instanceof _wooksjs_event_http.WooksHttp) this.httpApp = httpApp;
680
693
  else if (httpApp) this.httpApp = (0, _wooksjs_event_http.createHttpApp)({
package/dist/index.d.ts CHANGED
@@ -449,6 +449,17 @@ declare class MoostHttp implements TMoostAdapter<THttpHandlerMeta> {
449
449
  onNotFound(): Promise<unknown>;
450
450
  protected moost?: Moost;
451
451
  onInit(moost: Moost): void;
452
+ /**
453
+ * Called by `Moost.dispose()` before any `@MoostDispose` hook runs: stops the
454
+ * HTTP server this adapter started through {@link MoostHttp.listen}, so
455
+ * shutdown drains in-flight requests before singletons release what they own.
456
+ *
457
+ * A no-op when no server is listening — the adapter was used as a middleware
458
+ * (`getServerCb()`), `listen()` was never called (or failed), or the server is
459
+ * already closed. Guarding on the live server avoids wooks' `close()`
460
+ * never-settling (no server) and Node's `ERR_SERVER_NOT_RUNNING` (closed).
461
+ */
462
+ onDispose(): Promise<void>;
452
463
  getProvideRegistry(): moost.TProvideRegistry;
453
464
  getLogger(): TConsoleBase;
454
465
  bindHandler<T extends object = object>(opts: TMoostAdapterOptions<THttpHandlerMeta, T>): void;
package/dist/index.mjs CHANGED
@@ -615,6 +615,19 @@ const LOGGER_TITLE = "moost-http";
615
615
  onInit(moost) {
616
616
  this.moost = moost;
617
617
  }
618
+ /**
619
+ * Called by `Moost.dispose()` before any `@MoostDispose` hook runs: stops the
620
+ * HTTP server this adapter started through {@link MoostHttp.listen}, so
621
+ * shutdown drains in-flight requests before singletons release what they own.
622
+ *
623
+ * A no-op when no server is listening — the adapter was used as a middleware
624
+ * (`getServerCb()`), `listen()` was never called (or failed), or the server is
625
+ * already closed. Guarding on the live server avoids wooks' `close()`
626
+ * never-settling (no server) and Node's `ERR_SERVER_NOT_RUNNING` (closed).
627
+ */ async onDispose() {
628
+ if (!this.httpApp.getServer()?.listening) return;
629
+ await this.httpApp.close();
630
+ }
618
631
  getProvideRegistry() {
619
632
  return createProvideRegistry([WooksHttp, () => this.getHttpApp()], ["WooksHttp", () => this.getHttpApp()], [Server, () => this.getHttpApp().getServer()], [Server$1, () => this.getHttpApp().getServer()]);
620
633
  }
@@ -673,7 +686,7 @@ const LOGGER_TITLE = "moost-http";
673
686
  image: "https://moost.org/moost-full-logo.svg",
674
687
  link: "https://moost.org/",
675
688
  poweredBy: "moostjs",
676
- version: "0.6.35"
689
+ version: "0.6.36"
677
690
  });
678
691
  if (httpApp && httpApp instanceof WooksHttp) this.httpApp = httpApp;
679
692
  else if (httpApp) this.httpApp = createHttpApp({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-http",
3
- "version": "0.6.35",
3
+ "version": "0.6.36",
4
4
  "description": "@moostjs/event-http",
5
5
  "keywords": [
6
6
  "composables",
@@ -38,16 +38,16 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@wooksjs/event-http": "^0.7.22",
42
- "@wooksjs/http-body": "^0.7.22"
41
+ "@wooksjs/event-http": "^0.7.23",
42
+ "@wooksjs/http-body": "^0.7.23"
43
43
  },
44
44
  "devDependencies": {
45
45
  "vitest": "3.2.7"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@prostojs/infact": "^0.5.0",
49
- "@wooksjs/event-core": "^0.7.22",
50
- "moost": "^0.6.35"
49
+ "@wooksjs/event-core": "^0.7.23",
50
+ "moost": "^0.6.36"
51
51
  },
52
52
  "scripts": {
53
53
  "pub": "pnpm publish --access public",