@tsed/socketio 8.37.1 → 8.38.0-beta.2
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/lib/esm/SocketIOModule.js +18 -42
- package/lib/types/SocketIOModule.d.ts +4 -5
- package/package.json +15 -12
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Constant, Inject, InjectorService, Module } from "@tsed/di";
|
|
1
|
+
import { constant, inject, injectable, injector, logger } from "@tsed/di";
|
|
3
2
|
import { Server } from "socket.io";
|
|
4
3
|
import { $log } from "@tsed/logger";
|
|
5
4
|
import Http from "node:http";
|
|
6
5
|
import Https from "node:https";
|
|
7
|
-
import { IO } from "./decorators/io.js";
|
|
8
6
|
import { PROVIDER_TYPE_SOCKET_SERVICE } from "./constants/constants.js";
|
|
9
7
|
import { SocketIOService } from "./services/SocketIOService.js";
|
|
10
8
|
import { SocketProviderMetadata } from "./class/SocketProviderMetadata.js";
|
|
11
9
|
import { nameOf } from "@tsed/core";
|
|
10
|
+
import { $asyncEmit } from "@tsed/hooks";
|
|
12
11
|
/**
|
|
13
12
|
* @ignore
|
|
14
13
|
*/
|
|
15
|
-
|
|
14
|
+
export class SocketIOModule {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.disableRoutesSummary = constant("logger.disableRoutesSummary", false);
|
|
17
|
+
this.settings = constant("socketIO", {});
|
|
18
|
+
this.httpServer = inject(Http.Server);
|
|
19
|
+
this.httpsServer = inject(Https.Server);
|
|
20
|
+
this.socketIOService = inject(SocketIOService);
|
|
21
|
+
this.io = inject(Server);
|
|
22
|
+
}
|
|
16
23
|
$afterListen() {
|
|
17
24
|
if (this.httpServer) {
|
|
18
25
|
this.io.attach(this.httpServer, { ...this.settings });
|
|
@@ -24,7 +31,7 @@ let SocketIOModule = class SocketIOModule {
|
|
|
24
31
|
if (!this.disableRoutesSummary) {
|
|
25
32
|
this.printSocketEvents();
|
|
26
33
|
}
|
|
27
|
-
return
|
|
34
|
+
return $asyncEmit("$afterSocketListen");
|
|
28
35
|
}
|
|
29
36
|
$onDestroy() {
|
|
30
37
|
return this.io?.close && this.io?.engine && new Promise((resolve) => this.io.close(() => resolve(undefined)));
|
|
@@ -34,7 +41,7 @@ let SocketIOModule = class SocketIOModule {
|
|
|
34
41
|
* @returns {Provider<any>[]}
|
|
35
42
|
*/
|
|
36
43
|
getWebsocketServices() {
|
|
37
|
-
return
|
|
44
|
+
return injector().providers.getMany(PROVIDER_TYPE_SOCKET_SERVICE);
|
|
38
45
|
}
|
|
39
46
|
/**
|
|
40
47
|
*
|
|
@@ -55,7 +62,7 @@ let SocketIOModule = class SocketIOModule {
|
|
|
55
62
|
}
|
|
56
63
|
return acc;
|
|
57
64
|
}, []);
|
|
58
|
-
|
|
65
|
+
logger().info("Socket events mounted:");
|
|
59
66
|
const str = $log.drawTable(list, {
|
|
60
67
|
padding: 1,
|
|
61
68
|
header: {
|
|
@@ -66,39 +73,8 @@ let SocketIOModule = class SocketIOModule {
|
|
|
66
73
|
name: "Class method"
|
|
67
74
|
}
|
|
68
75
|
});
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
logger().info("\n" + str.trim());
|
|
77
|
+
logger().info("Socket server started...");
|
|
71
78
|
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
Constant("logger.disableRoutesSummary", false),
|
|
75
|
-
__metadata("design:type", Boolean)
|
|
76
|
-
], SocketIOModule.prototype, "disableRoutesSummary", void 0);
|
|
77
|
-
__decorate([
|
|
78
|
-
Constant("socketIO", {}),
|
|
79
|
-
__metadata("design:type", Object)
|
|
80
|
-
], SocketIOModule.prototype, "settings", void 0);
|
|
81
|
-
__decorate([
|
|
82
|
-
Inject(),
|
|
83
|
-
__metadata("design:type", InjectorService)
|
|
84
|
-
], SocketIOModule.prototype, "injector", void 0);
|
|
85
|
-
__decorate([
|
|
86
|
-
Inject(Http.Server),
|
|
87
|
-
__metadata("design:type", Object)
|
|
88
|
-
], SocketIOModule.prototype, "httpServer", void 0);
|
|
89
|
-
__decorate([
|
|
90
|
-
Inject(Https.Server),
|
|
91
|
-
__metadata("design:type", Object)
|
|
92
|
-
], SocketIOModule.prototype, "httpsServer", void 0);
|
|
93
|
-
__decorate([
|
|
94
|
-
IO(),
|
|
95
|
-
__metadata("design:type", Server)
|
|
96
|
-
], SocketIOModule.prototype, "io", void 0);
|
|
97
|
-
__decorate([
|
|
98
|
-
Inject(),
|
|
99
|
-
__metadata("design:type", SocketIOService)
|
|
100
|
-
], SocketIOModule.prototype, "socketIOService", void 0);
|
|
101
|
-
SocketIOModule = __decorate([
|
|
102
|
-
Module()
|
|
103
|
-
], SocketIOModule);
|
|
104
|
-
export { SocketIOModule };
|
|
79
|
+
}
|
|
80
|
+
injectable(SocketIOModule);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OnDestroy, Provider } from "@tsed/di";
|
|
2
2
|
import { ServerOptions } from "socket.io";
|
|
3
3
|
import type { AfterListen } from "@tsed/platform-http";
|
|
4
4
|
import Http from "node:http";
|
|
@@ -9,11 +9,10 @@ import Https from "node:https";
|
|
|
9
9
|
export declare class SocketIOModule implements AfterListen, OnDestroy {
|
|
10
10
|
protected disableRoutesSummary: boolean;
|
|
11
11
|
protected settings: Partial<ServerOptions>;
|
|
12
|
-
protected
|
|
13
|
-
protected
|
|
14
|
-
protected httpsServer: Https.Server | null;
|
|
15
|
-
private io;
|
|
12
|
+
protected httpServer: Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse> | null;
|
|
13
|
+
protected httpsServer: Https.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse> | null;
|
|
16
14
|
private socketIOService;
|
|
15
|
+
private io;
|
|
17
16
|
$afterListen(): Promise<void>;
|
|
18
17
|
$onDestroy(): Promise<unknown>;
|
|
19
18
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/socketio",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.38.0-beta.2",
|
|
4
4
|
"description": "Socket.io package for Ts.ED framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"realtime",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"tslib": ">=2.7.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tsed/barrels": "8.
|
|
38
|
-
"@tsed/core": "8.
|
|
39
|
-
"@tsed/di": "8.
|
|
40
|
-
"@tsed/json-mapper": "8.
|
|
41
|
-
"@tsed/openspec": "8.
|
|
42
|
-
"@tsed/platform-http": "8.
|
|
43
|
-
"@tsed/platform-middlewares": "8.
|
|
44
|
-
"@tsed/schema": "8.
|
|
45
|
-
"@tsed/socketio-testing": "8.
|
|
46
|
-
"@tsed/typescript": "8.
|
|
37
|
+
"@tsed/barrels": "8.38.0-beta.2",
|
|
38
|
+
"@tsed/core": "8.38.0-beta.2",
|
|
39
|
+
"@tsed/di": "8.38.0-beta.2",
|
|
40
|
+
"@tsed/json-mapper": "8.38.0-beta.2",
|
|
41
|
+
"@tsed/openspec": "8.38.0-beta.2",
|
|
42
|
+
"@tsed/platform-http": "8.38.0-beta.2",
|
|
43
|
+
"@tsed/platform-middlewares": "8.38.0-beta.2",
|
|
44
|
+
"@tsed/schema": "8.38.0-beta.2",
|
|
45
|
+
"@tsed/socketio-testing": "8.38.0-beta.2",
|
|
46
|
+
"@tsed/typescript": "8.38.0-beta.2",
|
|
47
47
|
"express": "5.2.1",
|
|
48
48
|
"socket.io": "4.8.0",
|
|
49
49
|
"socket.io-client": "^4.8.0",
|
|
@@ -78,5 +78,8 @@
|
|
|
78
78
|
},
|
|
79
79
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/third-parties/socketio",
|
|
80
80
|
"author": "Romain Lenzotti",
|
|
81
|
-
"license": "MIT"
|
|
81
|
+
"license": "MIT",
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"tag": "beta"
|
|
84
|
+
}
|
|
82
85
|
}
|