@opra/nestjs-socketio 1.21.0 → 1.22.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.
- package/{esm/opra-socketio-core.module.js → opra-socketio-core.module.js} +4 -0
- package/package.json +13 -30
- package/cjs/constants.js +0 -4
- package/cjs/index.js +0 -10
- package/cjs/opra-socketio-core.module.js +0 -147
- package/cjs/opra-socketio.module.js +0 -33
- package/cjs/package.json +0 -3
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -4
- /package/{types/constants.d.ts → constants.d.ts} +0 -0
- /package/{esm/constants.js → constants.js} +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/opra-socketio-core.module.d.ts → opra-socketio-core.module.d.ts} +0 -0
- /package/{types/opra-socketio.module.d.ts → opra-socketio.module.d.ts} +0 -0
- /package/{esm/opra-socketio.module.js → opra-socketio.module.js} +0 -0
|
@@ -9,6 +9,10 @@ import { SocketioAdapter } from '@opra/socketio';
|
|
|
9
9
|
import { OPRA_SOCKETIO_MODULE_OPTIONS } from './constants.js';
|
|
10
10
|
const opraSocketioNestjsAdapterToken = Symbol('OpraSocketioNestjsAdapter');
|
|
11
11
|
let OpraSocketioCoreModule = OpraSocketioCoreModule_1 = class OpraSocketioCoreModule {
|
|
12
|
+
controllerFactory;
|
|
13
|
+
adapter;
|
|
14
|
+
config;
|
|
15
|
+
httpAdapterHost;
|
|
12
16
|
constructor(controllerFactory, adapter, config, httpAdapterHost) {
|
|
13
17
|
this.controllerFactory = controllerFactory;
|
|
14
18
|
this.adapter = adapter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs-socketio",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.1",
|
|
4
4
|
"description": "Opra NestJS Socket.io Module",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,49 +9,32 @@
|
|
|
9
9
|
"tslib": "^2.8.1"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@opra/common": "^1.
|
|
13
|
-
"@opra/core": "^1.
|
|
14
|
-
"@opra/nestjs": "^1.
|
|
15
|
-
"@opra/socketio": "^1.
|
|
12
|
+
"@opra/common": "^1.22.1",
|
|
13
|
+
"@opra/core": "^1.22.1",
|
|
14
|
+
"@opra/nestjs": "^1.22.1",
|
|
15
|
+
"@opra/socketio": "^1.22.1",
|
|
16
16
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
17
17
|
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
18
|
-
"socket.io": "^4.8.
|
|
18
|
+
"socket.io": "^4.8.3"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
21
|
+
"module": "./index.js",
|
|
22
|
+
"types": "./index.d.ts",
|
|
21
23
|
"exports": {
|
|
22
24
|
".": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"default": "./esm/index.js"
|
|
26
|
-
},
|
|
27
|
-
"require": {
|
|
28
|
-
"types": "./types/index.d.cts",
|
|
29
|
-
"default": "./cjs/index.js"
|
|
30
|
-
},
|
|
31
|
-
"default": "./esm/index.js"
|
|
25
|
+
"types": "./index.d.ts",
|
|
26
|
+
"default": "./index.js"
|
|
32
27
|
},
|
|
33
28
|
"./package.json": "./package.json"
|
|
34
29
|
},
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20.0"
|
|
32
|
+
},
|
|
38
33
|
"repository": {
|
|
39
34
|
"type": "git",
|
|
40
35
|
"url": "git+https://github.com/panates/opra.git",
|
|
41
36
|
"directory": "packages/nestjs-socketio"
|
|
42
37
|
},
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=16.0",
|
|
45
|
-
"npm": ">=7.0.0"
|
|
46
|
-
},
|
|
47
|
-
"files": [
|
|
48
|
-
"bin/",
|
|
49
|
-
"cjs/",
|
|
50
|
-
"esm/",
|
|
51
|
-
"types/",
|
|
52
|
-
"LICENSE",
|
|
53
|
-
"README.md"
|
|
54
|
-
],
|
|
55
38
|
"keywords": [
|
|
56
39
|
"opra",
|
|
57
40
|
"nestjs",
|
package/cjs/constants.js
DELETED
package/cjs/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Public = exports.OpraNestUtils = exports.IS_PUBLIC_KEY = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const nestjs_1 = require("@opra/nestjs");
|
|
6
|
-
Object.defineProperty(exports, "IS_PUBLIC_KEY", { enumerable: true, get: function () { return nestjs_1.IS_PUBLIC_KEY; } });
|
|
7
|
-
Object.defineProperty(exports, "OpraNestUtils", { enumerable: true, get: function () { return nestjs_1.OpraNestUtils; } });
|
|
8
|
-
Object.defineProperty(exports, "Public", { enumerable: true, get: function () { return nestjs_1.Public; } });
|
|
9
|
-
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./opra-socketio.module.js"), exports);
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var OpraSocketioCoreModule_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OpraSocketioCoreModule = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const objects_1 = require("@jsopen/objects");
|
|
7
|
-
const common_1 = require("@nestjs/common");
|
|
8
|
-
const core_1 = require("@nestjs/core");
|
|
9
|
-
const common_2 = require("@opra/common");
|
|
10
|
-
const nestjs_1 = require("@opra/nestjs");
|
|
11
|
-
const socketio_1 = require("@opra/socketio");
|
|
12
|
-
const constants_js_1 = require("./constants.js");
|
|
13
|
-
const opraSocketioNestjsAdapterToken = Symbol('OpraSocketioNestjsAdapter');
|
|
14
|
-
let OpraSocketioCoreModule = OpraSocketioCoreModule_1 = class OpraSocketioCoreModule {
|
|
15
|
-
constructor(controllerFactory, adapter, config, httpAdapterHost) {
|
|
16
|
-
this.controllerFactory = controllerFactory;
|
|
17
|
-
this.adapter = adapter;
|
|
18
|
-
this.config = config;
|
|
19
|
-
this.httpAdapterHost = httpAdapterHost;
|
|
20
|
-
}
|
|
21
|
-
static forRoot(moduleOptions) {
|
|
22
|
-
return this._getDynamicModule({
|
|
23
|
-
...moduleOptions,
|
|
24
|
-
providers: [
|
|
25
|
-
...(moduleOptions?.providers || []),
|
|
26
|
-
{
|
|
27
|
-
provide: constants_js_1.OPRA_SOCKETIO_MODULE_OPTIONS,
|
|
28
|
-
useValue: {
|
|
29
|
-
...moduleOptions,
|
|
30
|
-
logger: moduleOptions.logger || new common_1.Logger(moduleOptions.name),
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
static forRootAsync(moduleOptions) {
|
|
37
|
-
if (!moduleOptions.useFactory)
|
|
38
|
-
throw new Error('Invalid configuration. Must provide "useFactory"');
|
|
39
|
-
return this._getDynamicModule({
|
|
40
|
-
...moduleOptions,
|
|
41
|
-
providers: [
|
|
42
|
-
...(moduleOptions?.providers || []),
|
|
43
|
-
{
|
|
44
|
-
provide: constants_js_1.OPRA_SOCKETIO_MODULE_OPTIONS,
|
|
45
|
-
inject: moduleOptions.inject,
|
|
46
|
-
useFactory: async (...args) => {
|
|
47
|
-
const result = await moduleOptions.useFactory(...args);
|
|
48
|
-
result.logger = result.logger || new common_1.Logger(result.name);
|
|
49
|
-
return result;
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
static _getDynamicModule(moduleOptions) {
|
|
56
|
-
const token = moduleOptions.token || socketio_1.SocketioAdapter;
|
|
57
|
-
const adapterProvider = {
|
|
58
|
-
provide: token,
|
|
59
|
-
inject: [nestjs_1.WSControllerFactory, core_1.ModuleRef, constants_js_1.OPRA_SOCKETIO_MODULE_OPTIONS],
|
|
60
|
-
useFactory: async (controllerFactory, moduleRef, config) => {
|
|
61
|
-
const controllers = controllerFactory
|
|
62
|
-
.exploreControllers()
|
|
63
|
-
.map(x => x.wrapper.instance);
|
|
64
|
-
const document = await common_2.ApiDocumentFactory.createDocument({
|
|
65
|
-
info: config.info,
|
|
66
|
-
types: config.types,
|
|
67
|
-
references: config.references,
|
|
68
|
-
api: {
|
|
69
|
-
name: config.name,
|
|
70
|
-
description: config.description,
|
|
71
|
-
transport: 'ws',
|
|
72
|
-
platform: socketio_1.SocketioAdapter.PlatformName,
|
|
73
|
-
controllers,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
const interceptors = moduleOptions.interceptors
|
|
77
|
-
? moduleOptions.interceptors.map(x => {
|
|
78
|
-
if ((0, objects_1.isConstructor)(x)) {
|
|
79
|
-
return async (ctx, next) => {
|
|
80
|
-
const interceptor = moduleRef.get(x);
|
|
81
|
-
if (typeof interceptor.intercept === 'function')
|
|
82
|
-
return interceptor.intercept(ctx, next);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return x;
|
|
86
|
-
})
|
|
87
|
-
: undefined;
|
|
88
|
-
return new socketio_1.SocketioAdapter(document, { ...config, interceptors });
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
return {
|
|
92
|
-
global: moduleOptions.global,
|
|
93
|
-
module: OpraSocketioCoreModule_1,
|
|
94
|
-
controllers: moduleOptions.controllers,
|
|
95
|
-
providers: [
|
|
96
|
-
...(moduleOptions?.providers || []),
|
|
97
|
-
nestjs_1.WSControllerFactory,
|
|
98
|
-
adapterProvider,
|
|
99
|
-
{
|
|
100
|
-
provide: opraSocketioNestjsAdapterToken,
|
|
101
|
-
useExisting: token,
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
imports: [...(moduleOptions?.imports || [])],
|
|
105
|
-
exports: [...(moduleOptions?.exports || []), adapterProvider],
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
onModuleInit() {
|
|
109
|
-
/** NestJS initialize controller instances on init stage.
|
|
110
|
-
* So we should update instance properties */
|
|
111
|
-
const wsApi = this.adapter.document.getWsApi();
|
|
112
|
-
const controllers = Array.from(wsApi.controllers.values());
|
|
113
|
-
for (const { wrapper } of this.controllerFactory
|
|
114
|
-
.exploreControllers()
|
|
115
|
-
.values()) {
|
|
116
|
-
const ctor = wrapper.instance.constructor;
|
|
117
|
-
const controller = controllers.find(x => x.ctor === ctor);
|
|
118
|
-
if (controller) {
|
|
119
|
-
controller.instance = wrapper.instance;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
async onApplicationBootstrap() {
|
|
124
|
-
const httpServer = this.httpAdapterHost.httpAdapter.getHttpServer();
|
|
125
|
-
if (this.config.port) {
|
|
126
|
-
const addr = httpServer.address();
|
|
127
|
-
const httpPort = addr && typeof addr === 'object' ? addr.port : 0;
|
|
128
|
-
if (httpPort !== this.config.port) {
|
|
129
|
-
this.adapter.listen(this.config.port, this.config.serverOptions);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
this.adapter.listen(httpServer, this.config.serverOptions);
|
|
134
|
-
}
|
|
135
|
-
async onApplicationShutdown() {
|
|
136
|
-
await this.adapter.close();
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
exports.OpraSocketioCoreModule = OpraSocketioCoreModule;
|
|
140
|
-
exports.OpraSocketioCoreModule = OpraSocketioCoreModule = OpraSocketioCoreModule_1 = tslib_1.__decorate([
|
|
141
|
-
(0, common_1.Module)({}),
|
|
142
|
-
(0, common_1.Global)(),
|
|
143
|
-
tslib_1.__param(1, (0, common_1.Inject)(opraSocketioNestjsAdapterToken)),
|
|
144
|
-
tslib_1.__param(2, (0, common_1.Inject)(constants_js_1.OPRA_SOCKETIO_MODULE_OPTIONS)),
|
|
145
|
-
tslib_1.__metadata("design:paramtypes", [nestjs_1.WSControllerFactory,
|
|
146
|
-
socketio_1.SocketioAdapter, Object, core_1.HttpAdapterHost])
|
|
147
|
-
], OpraSocketioCoreModule);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var OpraSocketioModule_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OpraSocketioModule = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const opra_socketio_core_module_js_1 = require("./opra-socketio-core.module.js");
|
|
8
|
-
let OpraSocketioModule = OpraSocketioModule_1 = class OpraSocketioModule {
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param init
|
|
12
|
-
*/
|
|
13
|
-
static forRoot(init) {
|
|
14
|
-
return {
|
|
15
|
-
module: OpraSocketioModule_1,
|
|
16
|
-
imports: [opra_socketio_core_module_js_1.OpraSocketioCoreModule.forRoot(init)],
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param options
|
|
22
|
-
*/
|
|
23
|
-
static forRootAsync(options) {
|
|
24
|
-
return {
|
|
25
|
-
module: OpraSocketioModule_1,
|
|
26
|
-
imports: [opra_socketio_core_module_js_1.OpraSocketioCoreModule.forRootAsync(options)],
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
exports.OpraSocketioModule = OpraSocketioModule;
|
|
31
|
-
exports.OpraSocketioModule = OpraSocketioModule = OpraSocketioModule_1 = tslib_1.__decorate([
|
|
32
|
-
(0, common_1.Module)({})
|
|
33
|
-
], OpraSocketioModule);
|
package/cjs/package.json
DELETED
package/esm/package.json
DELETED
package/types/index.d.cts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|