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