1 | /**
|
2 | * @external https://github.com/socketio/socket.io/blob/master/lib/index.ts
|
3 | */
|
4 | import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
5 | export interface GatewayMetadata {
|
6 | /**
|
7 | * The name of a namespace
|
8 | */
|
9 | namespace?: string | RegExp;
|
10 | /**
|
11 | * Name of the path to capture
|
12 | * @default "/socket.io"
|
13 | */
|
14 | path?: string;
|
15 | /**
|
16 | * Whether to serve the client files
|
17 | * @default true
|
18 | */
|
19 | serveClient?: boolean;
|
20 | /**
|
21 | * The adapter to use
|
22 | * @default the in-memory adapter (https://github.com/socketio/socket.io-adapter)
|
23 | */
|
24 | adapter?: any;
|
25 | /**
|
26 | * The parser to use
|
27 | * @default the default parser (https://github.com/socketio/socket.io-parser)
|
28 | */
|
29 | parser?: any;
|
30 | /**
|
31 | * How many ms before a client without namespace is closed
|
32 | * @default 45_000
|
33 | */
|
34 | connectTimeout?: number;
|
35 | /**
|
36 | * How many ms without a pong packet to consider the connection closed
|
37 | * @default 20_000
|
38 | */
|
39 | pingTimeout?: number;
|
40 | /**
|
41 | * How many ms before sending a new ping packet
|
42 | * @default 25_000
|
43 | */
|
44 | pingInterval?: number;
|
45 | /**
|
46 | * How many ms before an uncompleted transport upgrade is cancelled
|
47 | * @default 10_000
|
48 | */
|
49 | upgradeTimeout?: number;
|
50 | /**
|
51 | * How many bytes or characters a message can be, before closing the session (to avoid DoS).
|
52 | * @default 1e5 (100 KB)
|
53 | */
|
54 | maxHttpBufferSize?: number;
|
55 | /**
|
56 | * A function that receives a given handshake or upgrade request as its first parameter,
|
57 | * and can decide whether to continue or not. The second argument is a function that needs
|
58 | * to be called with the decided information: fn(err, success), where success is a boolean
|
59 | * value where false means that the request is rejected, and err is an error code.
|
60 | */
|
61 | allowRequest?: (req: any, fn: (err: string | null | undefined, success: boolean) => void) => void;
|
62 | /**
|
63 | * The low-level transports that are enabled
|
64 | * @default ["polling", "websocket"]
|
65 | */
|
66 | transports?: Array<'polling' | 'websocket'>;
|
67 | /**
|
68 | * Whether to allow transport upgrades
|
69 | * @default true
|
70 | */
|
71 | allowUpgrades?: boolean;
|
72 | /**
|
73 | * Parameters of the WebSocket permessage-deflate extension (see ws module api docs). Set to false to disable.
|
74 | * @default false
|
75 | */
|
76 | perMessageDeflate?: boolean | object;
|
77 | /**
|
78 | * Parameters of the http compression for the polling transports (see zlib api docs). Set to false to disable.
|
79 | * @default true
|
80 | */
|
81 | httpCompression?: boolean | object;
|
82 | /**
|
83 | * What WebSocket server implementation to use. Specified module must
|
84 | * conform to the ws interface (see ws module api docs). Default value is ws.
|
85 | * An alternative c++ addon is also available by installing uws module.
|
86 | */
|
87 | wsEngine?: string;
|
88 | /**
|
89 | * An optional packet which will be concatenated to the handshake packet emitted by Engine.IO.
|
90 | */
|
91 | initialPacket?: any;
|
92 | /**
|
93 | * Configuration of the cookie that contains the client sid to send as part of handshake response headers. This cookie
|
94 | * might be used for sticky-session. Defaults to not sending any cookie.
|
95 | * @default false
|
96 | */
|
97 | cookie?: any | boolean;
|
98 | /**
|
99 | * The options that will be forwarded to the cors module
|
100 | */
|
101 | cors?: CorsOptions;
|
102 | /**
|
103 | * Whether to enable compatibility with Socket.IO v2 clients
|
104 | * @default false
|
105 | */
|
106 | allowEIO3?: boolean;
|
107 | /**
|
108 | * Destroy unhandled upgrade requests
|
109 | * @default true
|
110 | */
|
111 | destroyUpgrade?: boolean;
|
112 | /**
|
113 | * Milliseconds after which unhandled requests are ended
|
114 | * @default 1_000
|
115 | */
|
116 | destroyUpgradeTimeout?: number;
|
117 | }
|