@feathersjs/socketio 5.0.0-pre.1 → 5.0.0-pre.15
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/CHANGELOG.md +162 -0
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/index.d.ts +8 -0
- package/lib/index.js +16 -20
- package/lib/index.js.map +1 -1
- package/lib/middleware.js +5 -17
- package/lib/middleware.js.map +1 -1
- package/package.json +17 -18
- package/src/index.ts +20 -18
- package/src/middleware.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,168 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09)
|
|
66
|
+
|
|
67
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09)
|
|
74
|
+
|
|
75
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08)
|
|
82
|
+
|
|
83
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### Features
|
|
93
|
+
|
|
94
|
+
* **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13)
|
|
101
|
+
|
|
102
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Bug Fixes
|
|
112
|
+
|
|
113
|
+
* **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
### Features
|
|
117
|
+
|
|
118
|
+
* **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
|
|
125
|
+
|
|
126
|
+
**Note:** Version bump only for package @feathersjs/socketio
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616))
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Bug Fixes
|
|
147
|
+
|
|
148
|
+
* Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60))
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Features
|
|
152
|
+
|
|
153
|
+
* **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d))
|
|
154
|
+
* Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6))
|
|
155
|
+
* Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9))
|
|
156
|
+
* **core:** Remove Uberproto ([#2178](https://github.com/feathersjs/feathers/issues/2178)) ([ddf8821](https://github.com/feathersjs/feathers/commit/ddf8821f53317e6a378657f7d66acb03a037ee47))
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
### BREAKING CHANGES
|
|
160
|
+
|
|
161
|
+
* **core:** Services no longer extend Uberproto objects and
|
|
162
|
+
`service.mixin()` is no longer available.
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
6
168
|
# [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17)
|
|
7
169
|
|
|
8
170
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -18,6 +18,6 @@ Refer to the [Feathers SocketIO API documentation](https://docs.feathersjs.com/a
|
|
|
18
18
|
|
|
19
19
|
## License
|
|
20
20
|
|
|
21
|
-
Copyright (c)
|
|
21
|
+
Copyright (c) 2021 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
22
22
|
|
|
23
23
|
Licensed under the [MIT license](LICENSE).
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import http from 'http';
|
|
1
3
|
import { Server, ServerOptions } from 'socket.io';
|
|
2
4
|
import { Application } from '@feathersjs/feathers';
|
|
5
|
+
declare module '@feathersjs/feathers/lib/declarations' {
|
|
6
|
+
interface Application<Services, Settings> {
|
|
7
|
+
io: Server;
|
|
8
|
+
listen(options: any): Promise<http.Server>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
3
11
|
declare function configureSocketio(callback?: (io: Server) => void): (app: Application) => void;
|
|
4
12
|
declare function configureSocketio(options: number | Partial<ServerOptions>, callback?: (io: Server) => void): (app: Application) => void;
|
|
5
13
|
declare function configureSocketio(port: number, options?: Partial<ServerOptions>, callback?: (io: Server) => void): (app: Application) => void;
|
package/lib/index.js
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const uberproto_1 = __importDefault(require("uberproto"));
|
|
7
|
-
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
const socket_io_1 = require("socket.io");
|
|
9
5
|
const http_1 = __importDefault(require("http"));
|
|
6
|
+
const socket_io_1 = require("socket.io");
|
|
7
|
+
const commons_1 = require("@feathersjs/commons");
|
|
10
8
|
const transport_commons_1 = require("@feathersjs/transport-commons");
|
|
11
9
|
const middleware_1 = require("./middleware");
|
|
12
|
-
const debug =
|
|
10
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/socketio');
|
|
13
11
|
function configureSocketio(port, options, config) {
|
|
14
12
|
if (typeof port !== 'number') {
|
|
15
13
|
config = options;
|
|
@@ -25,29 +23,27 @@ function configureSocketio(port, options, config) {
|
|
|
25
23
|
const getParams = (socket) => socket.feathers;
|
|
26
24
|
// A mapping from connection to socket instance
|
|
27
25
|
const socketMap = new WeakMap();
|
|
28
|
-
if (!app.version || app.version < '3.0.0') {
|
|
29
|
-
throw new Error('@feathersjs/socketio is not compatible with this version of Feathers. Use the latest at @feathersjs/feathers.');
|
|
30
|
-
}
|
|
31
26
|
// Promise that resolves with the Socket.io `io` instance
|
|
32
27
|
// when `setup` has been called (with a server)
|
|
33
28
|
const done = new Promise(resolve => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const { listen, setup } = app;
|
|
30
|
+
Object.assign(app, {
|
|
31
|
+
async listen(...args) {
|
|
32
|
+
if (typeof listen === 'function') {
|
|
37
33
|
// If `listen` already exists
|
|
38
34
|
// usually the case when the app has been expressified
|
|
39
|
-
return
|
|
35
|
+
return listen.call(this, ...args);
|
|
40
36
|
}
|
|
41
37
|
const server = http_1.default.createServer();
|
|
42
|
-
this.setup(server);
|
|
38
|
+
await this.setup(server);
|
|
43
39
|
return server.listen(...args);
|
|
44
40
|
},
|
|
45
|
-
setup(server) {
|
|
41
|
+
async setup(server, ...rest) {
|
|
46
42
|
if (!this.io) {
|
|
47
43
|
const io = this.io = new socket_io_1.Server(port || server, options);
|
|
48
|
-
io.use(middleware_1.disconnect(app, getParams));
|
|
49
|
-
io.use(middleware_1.params(app, socketMap));
|
|
50
|
-
io.use(middleware_1.authentication(app, getParams));
|
|
44
|
+
io.use((0, middleware_1.disconnect)(app, getParams));
|
|
45
|
+
io.use((0, middleware_1.params)(app, socketMap));
|
|
46
|
+
io.use((0, middleware_1.authentication)(app, getParams));
|
|
51
47
|
// In Feathers it is easy to hit the standard Node warning limit
|
|
52
48
|
// of event listeners (e.g. by registering 10 services).
|
|
53
49
|
// So we set it to a higher number. 64 should be enough for everyone.
|
|
@@ -58,11 +54,11 @@ function configureSocketio(port, options, config) {
|
|
|
58
54
|
config.call(this, this.io);
|
|
59
55
|
}
|
|
60
56
|
resolve(this.io);
|
|
61
|
-
return
|
|
57
|
+
return setup.call(this, server, ...rest);
|
|
62
58
|
}
|
|
63
|
-
}
|
|
59
|
+
});
|
|
64
60
|
});
|
|
65
|
-
app.configure(transport_commons_1.socket({
|
|
61
|
+
app.configure((0, transport_commons_1.socket)({
|
|
66
62
|
done,
|
|
67
63
|
socketMap,
|
|
68
64
|
getParams,
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,gDAAwB;AACxB,yCAAkD;AAClD,iDAAkD;AAElD,qEAAuD;AAEvD,6CAAkF;AAElF,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,sBAAsB,CAAC,CAAC;AAYlD,SAAS,iBAAiB,CAAE,IAAU,EAAE,OAAa,EAAE,MAAY;IACjE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,GAAG,OAAO,CAAC;QACjB,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,GAAG,IAAI,CAAC;KACb;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,MAAM,GAAG,OAAO,CAAC;QACjB,OAAO,GAAG,EAAE,CAAC;KACd;IAED,OAAO,CAAC,GAAgB,EAAE,EAAE;QAC1B,oCAAoC;QACpC,MAAM,SAAS,GAAG,CAAC,MAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC9D,+CAA+C;QAC/C,MAAM,SAAS,GAAG,IAAI,OAAO,EAAE,CAAC;QAChC,yDAAyD;QACzD,+CAA+C;QAC/C,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YACjC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAU,CAAC;YAErC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;gBACjB,KAAK,CAAC,MAAM,CAAa,GAAG,IAAW;oBACrC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;wBAChC,6BAA6B;wBAC7B,sDAAsD;wBACtD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;qBACnC;oBAED,MAAM,MAAM,GAAG,cAAI,CAAC,YAAY,EAAE,CAAC;oBAEnC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEzB,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;gBAChC,CAAC;gBAED,KAAK,CAAC,KAAK,CAAa,MAAmB,EAAE,GAAG,IAAW;oBACzD,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;wBACZ,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,kBAAM,CAAC,IAAI,IAAI,MAAM,EAAE,OAAO,CAAC,CAAC;wBAEzD,EAAE,CAAC,GAAG,CAAC,IAAA,uBAAU,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;wBACnC,EAAE,CAAC,GAAG,CAAC,IAAA,mBAAM,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;wBAC/B,EAAE,CAAC,GAAG,CAAC,IAAA,2BAAc,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;wBAEvC,gEAAgE;wBAChE,wDAAwD;wBACxD,qEAAqE;wBACrE,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;qBAChC;oBAED,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;wBAChC,KAAK,CAAC,yCAAyC,CAAC,CAAC;wBACjD,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;qBAC5B;oBAED,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAEjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC3C,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,SAAS,CAAC,IAAA,0BAAM,EAAC;YACnB,IAAI;YACJ,SAAS;YACT,SAAS;YACT,IAAI,EAAE,MAAM;SACb,CAAC,CAAC,CAAC;IACN,CAAC,CAAC;AACJ,CAAC;AAED,iBAAS,iBAAiB,CAAC"}
|
package/lib/middleware.js
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.authentication = exports.params = exports.disconnect = void 0;
|
|
16
|
-
const
|
|
17
|
-
const debug =
|
|
4
|
+
const commons_1 = require("@feathersjs/commons");
|
|
5
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/socketio/middleware');
|
|
18
6
|
const disconnect = (app, getParams) => (socket, next) => {
|
|
19
7
|
socket.once('disconnect', () => app.emit('disconnect', getParams(socket)));
|
|
20
8
|
next();
|
|
@@ -40,17 +28,17 @@ const authentication = (app, getParams, settings = {}) => (socket, next) => {
|
|
|
40
28
|
return next();
|
|
41
29
|
}
|
|
42
30
|
service.parse(socket.handshake, null, ...authStrategies)
|
|
43
|
-
.then((authentication) =>
|
|
31
|
+
.then(async (authentication) => {
|
|
44
32
|
if (authentication) {
|
|
45
33
|
debug('Parsed authentication from HTTP header', authentication);
|
|
46
34
|
socket.feathers.authentication = authentication;
|
|
47
|
-
|
|
35
|
+
await service.create(authentication, {
|
|
48
36
|
provider: 'socketio',
|
|
49
37
|
connection: getParams(socket)
|
|
50
38
|
});
|
|
51
39
|
}
|
|
52
40
|
next();
|
|
53
|
-
})
|
|
41
|
+
}).catch(next);
|
|
54
42
|
};
|
|
55
43
|
exports.authentication = authentication;
|
|
56
44
|
//# sourceMappingURL=middleware.js.map
|
package/lib/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":";;;AACA,iDAAkD;AAGlD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,iCAAiC,CAAC,CAAC;AAQtD,MAAM,UAAU,GAAG,CAAC,GAAgB,EAAE,SAAuB,EAAE,EAAE,CACtE,CAAC,MAAsB,EAAE,IAAkB,EAAE,EAAE;IAC7C,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3E,IAAI,EAAE,CAAC;AACT,CAAC,CAAA;AAJU,QAAA,UAAU,cAIpB;AAEI,MAAM,MAAM,GAAG,CAAC,IAAiB,EAAE,SAA4B,EAAE,EAAE,CACxE,CAAC,MAAsB,EAAE,IAAkB,EAAE,EAAE;IAC7C,MAAM,CAAC,QAAQ,GAAG;QAChB,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO;KAClC,CAAC;IAEF,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEvC,IAAI,EAAE,CAAC;AACT,CAAC,CAAA;AAVU,QAAA,MAAM,UAUhB;AAEI,MAAM,cAAc,GAAG,CAAC,GAAgB,EAAE,SAAuB,EAAE,WAAgB,EAAE,EAAE,EAAE,CAC9F,CAAC,MAAsB,EAAE,IAAkB,EAAE,EAAE;IAC7C,MAAM,OAAO,GAAI,GAAW,CAAC,qBAAqB,CAAC,CAAC,CAAE,GAAW,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEjH,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,IAAI,EAAE,CAAC;KACf;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IACrC,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC;IAE7E,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/B,OAAO,IAAI,EAAE,CAAC;KACf;IAED,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;SACrD,IAAI,CAAC,KAAK,EAAE,cAAmB,EAAE,EAAE;QAClC,IAAI,cAAc,EAAE;YAClB,KAAK,CAAC,wCAAwC,EAAE,cAAc,CAAC,CAAC;YAChE,MAAM,CAAC,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAC;YAChD,MAAM,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE;gBACnC,QAAQ,EAAE,UAAU;gBACpB,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC;aAC9B,CAAC,CAAC;SACJ;QAED,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC,CAAA;AA5BU,QAAA,cAAc,kBA4BxB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/socketio",
|
|
3
3
|
"description": "The Feathers Socket.io real-time API provider",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.15",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"url": "https://github.com/feathersjs/feathers/issues"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">= 12"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"CHANGELOG.md",
|
|
@@ -50,24 +50,23 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@feathersjs/
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
53
|
+
"@feathersjs/commons": "^5.0.0-pre.15",
|
|
54
|
+
"@feathersjs/feathers": "^5.0.0-pre.15",
|
|
55
|
+
"@feathersjs/transport-commons": "^5.0.0-pre.15",
|
|
56
|
+
"socket.io": "^4.3.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@feathersjs/
|
|
60
|
-
"@feathersjs/
|
|
61
|
-
"@feathersjs/
|
|
62
|
-
"@feathersjs/
|
|
63
|
-
"@
|
|
64
|
-
"@types/
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"mocha": "^8.2.1",
|
|
59
|
+
"@feathersjs/commons": "^5.0.0-pre.2",
|
|
60
|
+
"@feathersjs/express": "^5.0.0-pre.15",
|
|
61
|
+
"@feathersjs/memory": "^5.0.0-pre.15",
|
|
62
|
+
"@feathersjs/tests": "^5.0.0-pre.15",
|
|
63
|
+
"@types/mocha": "^9.0.0",
|
|
64
|
+
"@types/node": "^16.11.6",
|
|
65
|
+
"lodash": "^4.17.21",
|
|
66
|
+
"mocha": "^9.1.3",
|
|
68
67
|
"shx": "^0.3.3",
|
|
69
|
-
"socket.io-client": "^3.
|
|
70
|
-
"typescript": "^4.
|
|
68
|
+
"socket.io-client": "^4.3.2",
|
|
69
|
+
"typescript": "^4.4.4"
|
|
71
70
|
},
|
|
72
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "8008bf4f8529a2a40b6a2f976c1f43ae13675693"
|
|
73
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import Proto from 'uberproto';
|
|
3
|
-
import Debug from 'debug';
|
|
4
|
-
import { Server, ServerOptions } from 'socket.io';
|
|
5
1
|
import http from 'http';
|
|
2
|
+
import { Server, ServerOptions } from 'socket.io';
|
|
3
|
+
import { createDebug } from '@feathersjs/commons';
|
|
6
4
|
import { Application } from '@feathersjs/feathers';
|
|
7
5
|
import { socket } from '@feathersjs/transport-commons';
|
|
8
6
|
|
|
9
7
|
import { disconnect, params, authentication, FeathersSocket } from './middleware';
|
|
10
8
|
|
|
11
|
-
const debug =
|
|
9
|
+
const debug = createDebug('@feathersjs/socketio');
|
|
10
|
+
|
|
11
|
+
declare module '@feathersjs/feathers/lib/declarations' {
|
|
12
|
+
interface Application<Services, Settings> { // eslint-disable-line
|
|
13
|
+
io: Server;
|
|
14
|
+
listen (options: any): Promise<http.Server>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
12
17
|
|
|
13
18
|
function configureSocketio (callback?: (io: Server) => void): (app: Application) => void;
|
|
14
19
|
function configureSocketio (options: number | Partial<ServerOptions>, callback?: (io: Server) => void): (app: Application) => void;
|
|
@@ -30,30 +35,27 @@ function configureSocketio (port?: any, options?: any, config?: any) {
|
|
|
30
35
|
const getParams = (socket: FeathersSocket) => socket.feathers;
|
|
31
36
|
// A mapping from connection to socket instance
|
|
32
37
|
const socketMap = new WeakMap();
|
|
33
|
-
|
|
34
|
-
if (!app.version || app.version < '3.0.0') {
|
|
35
|
-
throw new Error('@feathersjs/socketio is not compatible with this version of Feathers. Use the latest at @feathersjs/feathers.');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
38
|
// Promise that resolves with the Socket.io `io` instance
|
|
39
39
|
// when `setup` has been called (with a server)
|
|
40
40
|
const done = new Promise(resolve => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const { listen, setup } = app as any;
|
|
42
|
+
|
|
43
|
+
Object.assign(app, {
|
|
44
|
+
async listen (this: any, ...args: any[]) {
|
|
45
|
+
if (typeof listen === 'function') {
|
|
44
46
|
// If `listen` already exists
|
|
45
47
|
// usually the case when the app has been expressified
|
|
46
|
-
return
|
|
48
|
+
return listen.call(this, ...args);
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
const server = http.createServer();
|
|
50
52
|
|
|
51
|
-
this.setup(server);
|
|
53
|
+
await this.setup(server);
|
|
52
54
|
|
|
53
55
|
return server.listen(...args);
|
|
54
56
|
},
|
|
55
57
|
|
|
56
|
-
setup (server: http.Server) {
|
|
58
|
+
async setup (this: any, server: http.Server, ...rest: any[]) {
|
|
57
59
|
if (!this.io) {
|
|
58
60
|
const io = this.io = new Server(port || server, options);
|
|
59
61
|
|
|
@@ -74,9 +76,9 @@ function configureSocketio (port?: any, options?: any, config?: any) {
|
|
|
74
76
|
|
|
75
77
|
resolve(this.io);
|
|
76
78
|
|
|
77
|
-
return
|
|
79
|
+
return setup.call(this, server, ...rest);
|
|
78
80
|
}
|
|
79
|
-
}
|
|
81
|
+
});
|
|
80
82
|
});
|
|
81
83
|
|
|
82
84
|
app.configure(socket({
|
package/src/middleware.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Application, Params } from '@feathersjs/feathers';
|
|
2
|
-
import
|
|
2
|
+
import { createDebug } from '@feathersjs/commons';
|
|
3
3
|
import { Socket } from 'socket.io';
|
|
4
4
|
|
|
5
|
-
const debug =
|
|
5
|
+
const debug = createDebug('@feathersjs/socketio/middleware');
|
|
6
6
|
|
|
7
7
|
export type ParamsGetter = (socket: Socket) => any;
|
|
8
8
|
export type NextFunction = (err?: any) => void;
|