@rest-vir/run-service 0.0.7 → 0.1.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.
|
@@ -25,12 +25,12 @@ export async function handleWebSocketRequest({ attachId, request, implementedWeb
|
|
|
25
25
|
protocols: restVirContext.protocols,
|
|
26
26
|
searchParams: restVirContext.searchParams,
|
|
27
27
|
};
|
|
28
|
-
if (implementedWebSocket.implementation.
|
|
28
|
+
if (implementedWebSocket.implementation.close) {
|
|
29
29
|
webSocket.on('close', async () => {
|
|
30
|
-
await implementedWebSocket.implementation.
|
|
30
|
+
await implementedWebSocket.implementation.close?.(webSocketCallbackParams);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
if (implementedWebSocket.implementation.
|
|
33
|
+
if (implementedWebSocket.implementation.message) {
|
|
34
34
|
webSocket.on('message', async (rawMessage) => {
|
|
35
35
|
let message;
|
|
36
36
|
try {
|
|
@@ -49,7 +49,7 @@ export async function handleWebSocketRequest({ attachId, request, implementedWeb
|
|
|
49
49
|
implementedWebSocket.service.logger.error(ensureErrorClass(error, RestVirHandlerError, implementedWebSocket, errorMessage));
|
|
50
50
|
}
|
|
51
51
|
try {
|
|
52
|
-
await implementedWebSocket.implementation.
|
|
52
|
+
await implementedWebSocket.implementation.message?.({
|
|
53
53
|
...webSocketCallbackParams,
|
|
54
54
|
message,
|
|
55
55
|
});
|
|
@@ -59,7 +59,7 @@ export async function handleWebSocketRequest({ attachId, request, implementedWeb
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
if (implementedWebSocket.implementation.
|
|
63
|
-
await implementedWebSocket.implementation.
|
|
62
|
+
if (implementedWebSocket.implementation.open) {
|
|
63
|
+
await implementedWebSocket.implementation.open(webSocketCallbackParams);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -199,10 +199,7 @@ export async function testExistingServer(server, service, options = {}) {
|
|
|
199
199
|
webSocket.dispatchEvent = (event) => {
|
|
200
200
|
return webSocket.emit(event.type, event);
|
|
201
201
|
};
|
|
202
|
-
/**
|
|
203
|
-
* `injectWS` does not fire the `'open'` event so we have to do it manually
|
|
204
|
-
* here.
|
|
205
|
-
*/
|
|
202
|
+
/** `injectWS` fires the `'open'` event before we have a chance to listen to it. */
|
|
206
203
|
webSocket.dispatchEvent(new Event('open'));
|
|
207
204
|
}
|
|
208
205
|
return finalized;
|
|
@@ -19,8 +19,10 @@ export const testWebSocket = async function testWebSocket(webSocketImplementatio
|
|
|
19
19
|
debug: true,
|
|
20
20
|
});
|
|
21
21
|
const webSocket = await connectWebSocket[webSocketImplementation.path](params);
|
|
22
|
-
webSocket.addEventListener('close',
|
|
23
|
-
|
|
22
|
+
webSocket.addEventListener('close', () => {
|
|
23
|
+
setTimeout(async () => {
|
|
24
|
+
await kill();
|
|
25
|
+
}, 1000);
|
|
24
26
|
});
|
|
25
27
|
return webSocket;
|
|
26
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/run-service",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Run a service defined by @rest-vir/define-service and implemented by @rest-vir/implement-service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rest",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@augment-vir/common": "^31.9.2",
|
|
44
44
|
"@augment-vir/node": "^31.9.2",
|
|
45
45
|
"@fastify/websocket": "^11.0.2",
|
|
46
|
-
"@rest-vir/define-service": "^0.0
|
|
47
|
-
"@rest-vir/implement-service": "^0.0
|
|
46
|
+
"@rest-vir/define-service": "^0.1.0",
|
|
47
|
+
"@rest-vir/implement-service": "^0.1.0",
|
|
48
48
|
"cluster-vir": "^0.1.0",
|
|
49
49
|
"date-vir": "^7.2.1",
|
|
50
50
|
"fastify": "^5.2.1",
|