@dunx/http 2.1.0 → 2.2.0
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/health/module.d.ts +1 -1
- package/dist/health/readiness.d.ts +5 -5
- package/dist/index.d.ts +8 -1
- package/dist/index.js +530 -42
- package/dist/index.js.map +18 -11
- package/dist/server/application.d.ts +31 -0
- package/dist/server/errors.d.ts +15 -1
- package/dist/server/factory.d.ts +1 -0
- package/dist/server/routes.d.ts +20 -0
- package/dist/static/module.d.ts +36 -2
- package/dist/throttle/decorators.d.ts +22 -0
- package/dist/throttle/guard.d.ts +31 -0
- package/dist/throttle/module.d.ts +35 -0
- package/dist/throttle/options.d.ts +52 -0
- package/dist/throttle/store.d.ts +71 -0
- package/dist/ws/adapter.d.ts +2 -1
- package/dist/ws/logging.d.ts +67 -0
- package/dist/ws/middleware.d.ts +80 -0
- package/dist/ws/socket.d.ts +13 -1
- package/package.json +2 -2
package/dist/health/module.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type HealthOptionsInit } from './registry.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Liveness and readiness, and the drain that makes readiness worth having.
|
|
5
5
|
*
|
|
6
|
-
* `Readiness` implements `
|
|
6
|
+
* `Readiness` implements `OnBeforeShutdown`, so readiness starts failing **before** the
|
|
7
7
|
* server stops accepting. Without that phase the flip was unexpressible: every
|
|
8
8
|
* `onShutdown` hook runs after `server.stop()` has resolved, so a probe answering
|
|
9
9
|
* from there answers on a closed port and the load balancer is still routing when
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OnBeforeShutdown } from '@dunx/core';
|
|
2
2
|
export interface ReadinessOptionsInit {
|
|
3
3
|
/**
|
|
4
4
|
* How long to keep failing readiness after the drain starts, before the server
|
|
@@ -21,15 +21,15 @@ export declare class ReadinessOptions {
|
|
|
21
21
|
* Whether this process wants traffic.
|
|
22
22
|
*
|
|
23
23
|
* Injectable, so a handler can pull the pod out of rotation for a migration and put
|
|
24
|
-
* it back. `hold` and `release` are for that; `
|
|
24
|
+
* it back. `hold` and `release` are for that; `onBeforeShutdown` is for shutdown and does not
|
|
25
25
|
* release.
|
|
26
26
|
*
|
|
27
|
-
* This is what `
|
|
27
|
+
* This is what `OnBeforeShutdown` was added to `@dunx/core` for. `HttpApplication.shutdown()`
|
|
28
28
|
* stopped the server before running any hook, so a readiness flip in `onShutdown`
|
|
29
29
|
* answered on a closed port, which is the wrong order: a load balancer has to see
|
|
30
30
|
* the probe fail while the port is still open.
|
|
31
31
|
*/
|
|
32
|
-
export declare class Readiness implements
|
|
32
|
+
export declare class Readiness implements OnBeforeShutdown {
|
|
33
33
|
#private;
|
|
34
34
|
private readonly options;
|
|
35
35
|
constructor(options: ReadinessOptions);
|
|
@@ -47,5 +47,5 @@ export declare class Readiness implements OnDrain {
|
|
|
47
47
|
* knows why it is waiting. `App.drain()` runs every hook under one `Promise.all`,
|
|
48
48
|
* so this window overlaps a queue worker's own drain instead of being added to it.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
onBeforeShutdown(): Promise<void>;
|
|
51
51
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { gatewaysOf, routesOf, type GatewayHandler, type GatewayNode, type Route
|
|
|
7
7
|
export { ClientAddress } from './server/client-address.js';
|
|
8
8
|
export { buildContext, type RouteContext } from './server/context.js';
|
|
9
9
|
export { preflight, withCors, type CorsOptions, type CorsOrigin, } from './server/cors.js';
|
|
10
|
-
export { defaultErrorMapper, ErrorFilter, errorMapper, HttpError, isErrorFilter, toErrorMapper, ValidationError, type ErrorHandler, type ErrorMapper, type InputSource, type ValidationIssue, } from './server/errors.js';
|
|
10
|
+
export { defaultErrorMapper, ErrorFilter, errorMapper, HttpError, isErrorFilter, toErrorMapper, ValidationError, type ErrorHandler, type ErrorMapper, type HttpErrorOptions, type InputSource, type ValidationIssue, } from './server/errors.js';
|
|
11
11
|
export { HttpFactory, type HttpApp, type HttpOptions, } from './server/factory.js';
|
|
12
12
|
export { REQUEST_ID_HEADER, RequestLoggingMiddleware, type RequestLoggingOptions, } from './server/request-logging.js';
|
|
13
13
|
export { compose, type Middleware, type Next, type RouteHandler, } from './server/middleware.js';
|
|
@@ -16,11 +16,18 @@ export type { AppSettings } from './server/settings.js';
|
|
|
16
16
|
export { StaticFiles } from './static/files.js';
|
|
17
17
|
export { StaticModule } from './static/module.js';
|
|
18
18
|
export { normalizePrefix, StaticOptions, type StaticOptionsInit, } from './static/options.js';
|
|
19
|
+
export { SKIP_THROTTLE, SkipThrottle, THROTTLE, Throttle, type ThrottleLimit, } from './throttle/decorators.js';
|
|
20
|
+
export { ThrottleGuard } from './throttle/guard.js';
|
|
21
|
+
export { ThrottleModule } from './throttle/module.js';
|
|
22
|
+
export { ThrottleOptions, type ThrottleOptionsInit, } from './throttle/options.js';
|
|
23
|
+
export { MemoryThrottleStore, RedisThrottleStore, ThrottleStore, type ThrottleRedis, } from './throttle/store.js';
|
|
19
24
|
export { HttpStatusCode, type HttpStatusName } from './server/status.js';
|
|
20
25
|
export { buildWebSocket, type UpgradeHandler, type WebSocketRuntime, } from './ws/adapter.js';
|
|
21
26
|
export { Gateway, OnClose, OnDrain, OnMessage, OnOpen, OnPing, OnPong, OnUpgrade, } from './ws/decorators.js';
|
|
22
27
|
export { discoverGateway, discoverGateways, normalizePath, type DiscoveredGateway, type DiscoveredHandler, type Invoke, } from './ws/discover.js';
|
|
23
28
|
export { decode, encode, type Envelope } from './ws/envelope.js';
|
|
29
|
+
export { composeSocket, observe, type SocketContext, type SocketDispatch, type SocketFrame, type SocketMiddleware, type SocketNext, } from './ws/middleware.js';
|
|
30
|
+
export { SocketLoggingMiddleware, type SocketLoggingOptions, } from './ws/logging.js';
|
|
24
31
|
export { HandlerKind, isGateway, type HandlerMeta } from './ws/marker.js';
|
|
25
32
|
export { PubSub } from './ws/pubsub.js';
|
|
26
33
|
export { defaultRelayUrl, RedisRelay, type RedisRelayOptions, } from './ws/redis-relay.js';
|