@dunx/http 2.0.1 → 2.1.1

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.
@@ -1,4 +1,4 @@
1
- import type { Ctor, ModuleRef } from '@dunx/core';
1
+ import { type Ctor, type ModuleRef } from '@dunx/core';
2
2
  import type { Middleware } from '../server/middleware.js';
3
3
  import { type HttpMethod } from './marker.js';
4
4
  import { type MetaRecord } from './metadata.js';
@@ -132,6 +132,12 @@ export declare class HttpApplication implements HttpApp {
132
132
  * matches an upgrade, and no `fetch` handler is needed at all.
133
133
  */
134
134
  listen(port?: number): Promise<string>;
135
+ /**
136
+ * Delegated unchanged: the drain is the container's phase, and `shutdown()`
137
+ * runs it. Public so an operator can start draining without committing to a
138
+ * shutdown, which is what a readiness probe wants during a rolling deploy.
139
+ */
140
+ drain(): Promise<void>;
135
141
  shutdown(): Promise<void>;
136
142
  enableShutdownHooks(signals?: readonly ShutdownSignal[], options?: ShutdownHookOptions): this;
137
143
  }
@@ -1,11 +1,17 @@
1
1
  import type { BunRequest, Server } from 'bun';
2
2
  export interface AddressSource {
3
3
  readonly server: Server<unknown>;
4
- readonly trustProxy: boolean;
4
+ readonly trustProxy: boolean | number;
5
5
  }
6
6
  /**
7
7
  * The client's address, honouring the `'trust proxy'` setting.
8
8
  *
9
+ * With the setting on, the address is read from `X-Forwarded-For` counting from
10
+ * the right by the number of trusted hops, never from the left. A client can put
11
+ * anything in the header it sends; only the entries a proxy appended carry any
12
+ * weight, and there are exactly as many of those as there are proxies in front of
13
+ * this server.
14
+ *
9
15
  * Bound and exported by `HttpFactory`'s global wrapper module, so injecting it in a
10
16
  * middleware or controller needs no registration and `app.clientIp(req)` is the same
11
17
  * instance. That binding is not optional under module scoping: an unbound class
@@ -5,10 +5,15 @@
5
5
  */
6
6
  export interface AppSettings {
7
7
  /**
8
- * Resolve the client address from `X-Forwarded-For` rather than the socket. Only
9
- * turn it on behind a proxy that rewrites the header: a direct client can send
10
- * whatever it likes.
8
+ * Resolve the client address from `X-Forwarded-For` rather than the socket.
9
+ *
10
+ * The value is how many proxies sit in front of this server: `true` means one,
11
+ * a number means that many, `false` means read the socket. The address is taken
12
+ * that many entries from the **right**, because a direct client can send
13
+ * whatever it likes in the header and only a proxy under your control appends
14
+ * to it. Setting a count higher than the number of proxies you actually run
15
+ * hands the caller its own choice of address.
11
16
  */
12
- 'trust proxy': boolean;
17
+ 'trust proxy': boolean | number;
13
18
  }
14
19
  export declare const defaultSettings: () => AppSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dunx/http",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Bun.serve adapter for the dunx framework: controllers, middleware and WebSocket gateways",
5
5
  "keywords": [
6
6
  "bun",
@@ -58,7 +58,7 @@
58
58
  "@dunx/core": "workspace:*"
59
59
  },
60
60
  "peerDependencies": {
61
- "@dunx/core": "^2.0.1",
61
+ "@dunx/core": "^2.1.1",
62
62
  "@types/bun": ">=1.3.0"
63
63
  },
64
64
  "peerDependenciesMeta": {