@rest-vir/implement-service 0.11.3 → 0.12.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.
|
@@ -63,6 +63,18 @@ export type EndpointImplementationParams<Context = any, ServiceName extends stri
|
|
|
63
63
|
response: ServerResponse;
|
|
64
64
|
log: Readonly<ServiceLogger>;
|
|
65
65
|
searchParams: SpecificEndpoint extends NoParam ? BaseSearchParams : Exclude<SpecificEndpoint, NoParam>['SearchParamsType'];
|
|
66
|
+
/** The actual running server info. */
|
|
67
|
+
server: RunningServerInfo;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Information passed to an endpoint or WebSocket about the currently running server.
|
|
71
|
+
*
|
|
72
|
+
* @category Internal
|
|
73
|
+
* @category Package : @rest-vir/implement-service
|
|
74
|
+
* @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
|
|
75
|
+
*/
|
|
76
|
+
export type RunningServerInfo = {
|
|
77
|
+
serviceOrigin: string;
|
|
66
78
|
};
|
|
67
79
|
/**
|
|
68
80
|
* Generic parameters for {@link EndpointImplementation} that should be compatible with _any_
|
|
@@ -84,6 +96,8 @@ export type GenericEndpointImplementationParams = {
|
|
|
84
96
|
request: ServerRequest;
|
|
85
97
|
response: ServerResponse;
|
|
86
98
|
log: Readonly<ServiceLogger>;
|
|
99
|
+
/** The actual running server info. */
|
|
100
|
+
server: RunningServerInfo;
|
|
87
101
|
};
|
|
88
102
|
/**
|
|
89
103
|
* A full, type-safe endpoint implementation type.
|
|
@@ -4,6 +4,7 @@ import { type IncomingHttpHeaders } from 'node:http';
|
|
|
4
4
|
import { type IsEqual } from 'type-fest';
|
|
5
5
|
import { type ServerRequest, type ServerWebSocket } from '../util/data.js';
|
|
6
6
|
import { type ServiceLogger } from '../util/service-logger.js';
|
|
7
|
+
import { type RunningServerInfo } from './implement-endpoint.js';
|
|
7
8
|
/**
|
|
8
9
|
* A WebSocket implementation, with callbacks for WebSocket events.
|
|
9
10
|
*
|
|
@@ -59,6 +60,8 @@ export type WebSocketImplementationParams<Context = any, ServiceName extends str
|
|
|
59
60
|
request: ServerRequest;
|
|
60
61
|
protocols: SpecificWebSocket extends NoParam ? string[] : Exclude<SpecificWebSocket, NoParam>['ProtocolsType'];
|
|
61
62
|
searchParams: SpecificWebSocket extends NoParam ? BaseSearchParams : Exclude<SpecificWebSocket, NoParam>['SearchParamsType'];
|
|
63
|
+
/** The actual running server info. */
|
|
64
|
+
server: RunningServerInfo;
|
|
62
65
|
} & (IsEqual<WithMessage, true> extends true ? {
|
|
63
66
|
message: SpecificWebSocket extends NoParam ? any : Exclude<SpecificWebSocket, NoParam>['MessageFromClientType'];
|
|
64
67
|
} : unknown);
|
|
@@ -3,7 +3,7 @@ import { type BaseServiceEndpointsInit, type BaseServiceWebSocketsInit, type End
|
|
|
3
3
|
import { type IncomingHttpHeaders } from 'node:http';
|
|
4
4
|
import { type RequireExactlyOne } from 'type-fest';
|
|
5
5
|
import { type ServerRequest, type ServerResponse } from '../util/data.js';
|
|
6
|
-
import { EndpointImplementationErrorOutput } from './implement-endpoint.js';
|
|
6
|
+
import { EndpointImplementationErrorOutput, type RunningServerInfo } from './implement-endpoint.js';
|
|
7
7
|
/**
|
|
8
8
|
* User-defined service implementation Context generator.
|
|
9
9
|
*
|
|
@@ -34,6 +34,8 @@ export type ContextInitParameters<ServiceName extends string = any, EndpointsIni
|
|
|
34
34
|
requestData: EndpointsInit extends NoParam ? unknown : WithFinalEndpointProps<Values<EndpointsInit>, Extract<keyof EndpointsInit, EndpointPathBase>>['RequestType'];
|
|
35
35
|
request: ServerRequest;
|
|
36
36
|
response: ServerResponse;
|
|
37
|
+
/** The actual running server info. */
|
|
38
|
+
server: RunningServerInfo;
|
|
37
39
|
endpointDefinition?: (EndpointsInit extends NoParam ? EndpointDefinition : WithFinalEndpointProps<Values<EndpointsInit>, Extract<keyof EndpointsInit, EndpointPathBase>>) | undefined;
|
|
38
40
|
webSocketDefinition?: (WebSocketsInit extends NoParam ? WebSocketDefinition : WithFinalWebSocketProps<Values<WebSocketsInit>, Extract<keyof WebSocketsInit, EndpointPathBase>>) | undefined;
|
|
39
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/implement-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Implement a service defined by @rest-vir/define-service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rest",
|
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
"test:update": "npm test update"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/assert": "^31.
|
|
43
|
-
"@augment-vir/common": "^31.
|
|
44
|
-
"@rest-vir/define-service": "^0.
|
|
42
|
+
"@augment-vir/assert": "^31.11.0",
|
|
43
|
+
"@augment-vir/common": "^31.11.0",
|
|
44
|
+
"@rest-vir/define-service": "^0.12.0",
|
|
45
45
|
"@types/ws": "^8.18.1",
|
|
46
|
-
"fastify": "^5.
|
|
46
|
+
"fastify": "^5.3.0",
|
|
47
47
|
"path-to-regexp": "^8.2.0",
|
|
48
|
-
"type-fest": "^4.
|
|
48
|
+
"type-fest": "^4.40.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@augment-vir/test": "^31.
|
|
52
|
-
"@types/node": "^22.14.
|
|
51
|
+
"@augment-vir/test": "^31.11.0",
|
|
52
|
+
"@types/node": "^22.14.1",
|
|
53
53
|
"c8": "^10.1.3",
|
|
54
54
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
55
55
|
"markdown-code-example-inserter": "^3.0.3",
|