@eleven-am/pondsocket-express 0.0.38 → 0.0.39
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/index.d.ts +13 -34
- package/index.js +12 -16
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Server } from 'http';
|
|
2
|
+
import { PondSocket } from '@eleven-am/pondsocket';
|
|
3
|
+
import type { Endpoint, PondPath, PondSocketOptions } from '@eleven-am/pondsocket/types';
|
|
2
4
|
import type { Express } from 'express';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
type EndpointHandler<Path extends string> = Parameters<PondSocket['createEndpoint']>[1];
|
|
6
|
+
export interface PondSocketExpress {
|
|
7
|
+
app: Express;
|
|
8
|
+
server: Server;
|
|
9
|
+
pond: PondSocket;
|
|
10
|
+
createEndpoint<Path extends string>(path: PondPath<Path>, handler: EndpointHandler<Path>): Endpoint;
|
|
11
|
+
listen(...args: any[]): Server;
|
|
12
|
+
close(callback?: (err?: Error) => void, timeout?: number): Server;
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @desc Accepts a new socket upgrade request on the provided endpoint using the handler function to authenticate the socket
|
|
13
|
-
* @param path - the pattern to accept || can also be a regex
|
|
14
|
-
* @param handler - the handler function to authenticate the socket
|
|
15
|
-
* @example
|
|
16
|
-
* const endpoint = pond.createEndpoint('/api/socket', (req, res) => {
|
|
17
|
-
* const token = req.query.token;
|
|
18
|
-
* if (!token)
|
|
19
|
-
* return res.reject("No token provided");
|
|
20
|
-
* res.accept({
|
|
21
|
-
* assign: {
|
|
22
|
-
* token
|
|
23
|
-
* }
|
|
24
|
-
* });
|
|
25
|
-
* })
|
|
26
|
-
*/
|
|
27
|
-
createEndpoint<Path extends string>(path: PondPath<Path>, handler: RequestHandler<ConnectionContext<Path>>): Endpoint;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @desc Creates a pond socket server
|
|
31
|
-
* @param app - The Express app to be used by the server
|
|
32
|
-
* @param options - The options to be used by the pond socket server
|
|
33
|
-
* @constructor
|
|
34
|
-
*/
|
|
35
|
-
declare const pondSocket: (app: Express, options: Omit<PondSocketOptions, "server">) => PondSocketExpressApp;
|
|
36
|
-
export default pondSocket;
|
|
14
|
+
declare const createPondSocket: (app: Express, options?: Omit<PondSocketOptions, "server">) => PondSocketExpress;
|
|
15
|
+
export default createPondSocket;
|
package/index.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const http_1 = require("http");
|
|
7
|
-
const pondsocket_1 =
|
|
8
|
-
|
|
9
|
-
* @desc Creates a pond socket server
|
|
10
|
-
* @param app - The Express app to be used by the server
|
|
11
|
-
* @param options - The options to be used by the pond socket server
|
|
12
|
-
* @constructor
|
|
13
|
-
*/
|
|
14
|
-
const pondSocket = (app, options) => {
|
|
4
|
+
const pondsocket_1 = require("@eleven-am/pondsocket");
|
|
5
|
+
const createPondSocket = (app, options = {}) => {
|
|
15
6
|
const server = (0, http_1.createServer)(app);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const pond = new pondsocket_1.PondSocket(Object.assign(Object.assign({}, options), { server }));
|
|
8
|
+
return {
|
|
9
|
+
app,
|
|
10
|
+
server,
|
|
11
|
+
pond,
|
|
12
|
+
createEndpoint: (path, handler) => pond.createEndpoint(path, handler),
|
|
13
|
+
listen: (...args) => pond.listen(...args),
|
|
14
|
+
close: (callback, timeout) => pond.close(callback, timeout),
|
|
15
|
+
};
|
|
20
16
|
};
|
|
21
|
-
exports.default =
|
|
17
|
+
exports.default = createPondSocket;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eleven-am/pondsocket-express",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "PondSocket is a fast simple socket server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"socket",
|
|
@@ -29,23 +29,23 @@
|
|
|
29
29
|
"pipeline": "npm run lint:fix && npm run lint && npm run build && npm run push"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eleven-am/pondsocket": "^0.1.
|
|
32
|
+
"@eleven-am/pondsocket": "^0.1.215"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/compat": "^1.4.0",
|
|
36
|
-
"@eslint/eslintrc": "^3.3.
|
|
36
|
+
"@eslint/eslintrc": "^3.3.4",
|
|
37
37
|
"@eslint/js": "^9.38.0",
|
|
38
38
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
39
|
-
"@types/express": "^5.0.
|
|
39
|
+
"@types/express": "^5.0.6",
|
|
40
40
|
"@types/jest": "^30.0.0",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
42
42
|
"eslint": "^9.38.0",
|
|
43
43
|
"eslint-plugin-file-progress": "^3.0.2",
|
|
44
44
|
"eslint-plugin-import": "^2.32.0",
|
|
45
45
|
"globals": "^16.4.0",
|
|
46
46
|
"jest": "^30.2.0",
|
|
47
|
-
"prettier": "^3.
|
|
48
|
-
"ts-jest": "^29.4.
|
|
47
|
+
"prettier": "^3.8.1",
|
|
48
|
+
"ts-jest": "^29.4.6",
|
|
49
49
|
"ts-loader": "^9.5.4",
|
|
50
50
|
"ts-node": "^10.9.2",
|
|
51
51
|
"typescript": "^5.9.3"
|