@nmtjs/ws-transport 0.12.4 → 0.12.6
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/dist/http.d.ts +80 -0
- package/dist/http.js +142 -144
- package/dist/index.d.ts +5 -0
- package/dist/index.js +0 -2
- package/dist/injectables.d.ts +14 -0
- package/dist/injectables.js +4 -6
- package/dist/server.d.ts +27 -0
- package/dist/server.js +402 -364
- package/dist/transport.d.ts +2 -0
- package/dist/transport.js +3 -5
- package/dist/types.d.ts +26 -0
- package/dist/types.js +0 -2
- package/dist/utils.d.ts +26 -0
- package/dist/utils.js +79 -78
- package/package.json +11 -10
- package/src/types.ts +1 -1
- package/dist/http.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/injectables.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/transport.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare enum HttpCode {
|
|
2
|
+
Continue = 100,
|
|
3
|
+
SwitchingProtocols = 101,
|
|
4
|
+
Processing = 102,
|
|
5
|
+
EarlyHints = 103,
|
|
6
|
+
OK = 200,
|
|
7
|
+
Created = 201,
|
|
8
|
+
Accepted = 202,
|
|
9
|
+
NonAuthoritativeInformation = 203,
|
|
10
|
+
NoContent = 204,
|
|
11
|
+
ResetContent = 205,
|
|
12
|
+
PartialContent = 206,
|
|
13
|
+
MultiStatus = 207,
|
|
14
|
+
AlreadyReported = 208,
|
|
15
|
+
IMUsed = 226,
|
|
16
|
+
MultipleChoices = 300,
|
|
17
|
+
MovedPermanently = 301,
|
|
18
|
+
Found = 302,
|
|
19
|
+
SeeOther = 303,
|
|
20
|
+
NotModified = 304,
|
|
21
|
+
UseProxy = 305,
|
|
22
|
+
TemporaryRedirect = 307,
|
|
23
|
+
PermanentRedirect = 308,
|
|
24
|
+
BadRequest = 400,
|
|
25
|
+
Unauthorized = 401,
|
|
26
|
+
PaymentRequired = 402,
|
|
27
|
+
Forbidden = 403,
|
|
28
|
+
NotFound = 404,
|
|
29
|
+
MethodNotAllowed = 405,
|
|
30
|
+
NotAcceptable = 406,
|
|
31
|
+
ProxyAuthenticationRequired = 407,
|
|
32
|
+
RequestTimeout = 408,
|
|
33
|
+
Conflict = 409,
|
|
34
|
+
Gone = 410,
|
|
35
|
+
LengthRequired = 411,
|
|
36
|
+
PreconditionFailed = 412,
|
|
37
|
+
PayloadTooLarge = 413,
|
|
38
|
+
URITooLong = 414,
|
|
39
|
+
UnsupportedMediaType = 415,
|
|
40
|
+
RangeNotSatisfiable = 416,
|
|
41
|
+
ExpectationFailed = 417,
|
|
42
|
+
ImATeapot = 418,
|
|
43
|
+
MisdirectedRequest = 421,
|
|
44
|
+
UnprocessableEntity = 422,
|
|
45
|
+
Locked = 423,
|
|
46
|
+
FailedDependency = 424,
|
|
47
|
+
TooEarly = 425,
|
|
48
|
+
UpgradeRequired = 426,
|
|
49
|
+
PreconditionRequired = 428,
|
|
50
|
+
TooManyRequests = 429,
|
|
51
|
+
RequestHeaderFieldsTooLarge = 431,
|
|
52
|
+
UnavailableForLegalReasons = 451,
|
|
53
|
+
InternalServerError = 500,
|
|
54
|
+
NotImplemented = 501,
|
|
55
|
+
BadGateway = 502,
|
|
56
|
+
ServiceUnavailable = 503,
|
|
57
|
+
GatewayTimeout = 504,
|
|
58
|
+
HTTPVersionNotSupported = 505,
|
|
59
|
+
VariantAlsoNegotiates = 506,
|
|
60
|
+
InsufficientStorage = 507,
|
|
61
|
+
LoopDetected = 508,
|
|
62
|
+
NotExtended = 510,
|
|
63
|
+
NetworkAuthenticationRequired = 511
|
|
64
|
+
}
|
|
65
|
+
export declare const HttpStatusText: Record<HttpCode, string>;
|
|
66
|
+
export declare const HttpCodeMap: {
|
|
67
|
+
ValidationError: HttpCode;
|
|
68
|
+
BadRequest: HttpCode;
|
|
69
|
+
NotFound: HttpCode;
|
|
70
|
+
Forbidden: HttpCode;
|
|
71
|
+
Unauthorized: HttpCode;
|
|
72
|
+
InternalServerError: HttpCode;
|
|
73
|
+
NotAcceptable: HttpCode;
|
|
74
|
+
RequestTimeout: HttpCode;
|
|
75
|
+
GatewayTimeout: HttpCode;
|
|
76
|
+
ServiceUnavailable: HttpCode;
|
|
77
|
+
ClientRequestError: HttpCode;
|
|
78
|
+
ConnectionError: HttpCode;
|
|
79
|
+
};
|
|
80
|
+
export declare const AllowedHttpMethod: import("@nmtjs/core").MetadataKey<("get" | "post")[]>;
|
package/dist/http.js
CHANGED
|
@@ -1,148 +1,146 @@
|
|
|
1
|
-
import { createMetadataKey } from
|
|
2
|
-
import { ErrorCode } from
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}({});
|
|
1
|
+
import { createMetadataKey } from '@nmtjs/core';
|
|
2
|
+
import { ErrorCode } from '@nmtjs/protocol';
|
|
3
|
+
export var HttpCode;
|
|
4
|
+
(function (HttpCode) {
|
|
5
|
+
HttpCode[HttpCode["Continue"] = 100] = "Continue";
|
|
6
|
+
HttpCode[HttpCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
7
|
+
HttpCode[HttpCode["Processing"] = 102] = "Processing";
|
|
8
|
+
HttpCode[HttpCode["EarlyHints"] = 103] = "EarlyHints";
|
|
9
|
+
HttpCode[HttpCode["OK"] = 200] = "OK";
|
|
10
|
+
HttpCode[HttpCode["Created"] = 201] = "Created";
|
|
11
|
+
HttpCode[HttpCode["Accepted"] = 202] = "Accepted";
|
|
12
|
+
HttpCode[HttpCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
13
|
+
HttpCode[HttpCode["NoContent"] = 204] = "NoContent";
|
|
14
|
+
HttpCode[HttpCode["ResetContent"] = 205] = "ResetContent";
|
|
15
|
+
HttpCode[HttpCode["PartialContent"] = 206] = "PartialContent";
|
|
16
|
+
HttpCode[HttpCode["MultiStatus"] = 207] = "MultiStatus";
|
|
17
|
+
HttpCode[HttpCode["AlreadyReported"] = 208] = "AlreadyReported";
|
|
18
|
+
HttpCode[HttpCode["IMUsed"] = 226] = "IMUsed";
|
|
19
|
+
HttpCode[HttpCode["MultipleChoices"] = 300] = "MultipleChoices";
|
|
20
|
+
HttpCode[HttpCode["MovedPermanently"] = 301] = "MovedPermanently";
|
|
21
|
+
HttpCode[HttpCode["Found"] = 302] = "Found";
|
|
22
|
+
HttpCode[HttpCode["SeeOther"] = 303] = "SeeOther";
|
|
23
|
+
HttpCode[HttpCode["NotModified"] = 304] = "NotModified";
|
|
24
|
+
HttpCode[HttpCode["UseProxy"] = 305] = "UseProxy";
|
|
25
|
+
HttpCode[HttpCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
26
|
+
HttpCode[HttpCode["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
27
|
+
HttpCode[HttpCode["BadRequest"] = 400] = "BadRequest";
|
|
28
|
+
HttpCode[HttpCode["Unauthorized"] = 401] = "Unauthorized";
|
|
29
|
+
HttpCode[HttpCode["PaymentRequired"] = 402] = "PaymentRequired";
|
|
30
|
+
HttpCode[HttpCode["Forbidden"] = 403] = "Forbidden";
|
|
31
|
+
HttpCode[HttpCode["NotFound"] = 404] = "NotFound";
|
|
32
|
+
HttpCode[HttpCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
33
|
+
HttpCode[HttpCode["NotAcceptable"] = 406] = "NotAcceptable";
|
|
34
|
+
HttpCode[HttpCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
35
|
+
HttpCode[HttpCode["RequestTimeout"] = 408] = "RequestTimeout";
|
|
36
|
+
HttpCode[HttpCode["Conflict"] = 409] = "Conflict";
|
|
37
|
+
HttpCode[HttpCode["Gone"] = 410] = "Gone";
|
|
38
|
+
HttpCode[HttpCode["LengthRequired"] = 411] = "LengthRequired";
|
|
39
|
+
HttpCode[HttpCode["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
40
|
+
HttpCode[HttpCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
41
|
+
HttpCode[HttpCode["URITooLong"] = 414] = "URITooLong";
|
|
42
|
+
HttpCode[HttpCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
43
|
+
HttpCode[HttpCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
44
|
+
HttpCode[HttpCode["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
45
|
+
HttpCode[HttpCode["ImATeapot"] = 418] = "ImATeapot";
|
|
46
|
+
HttpCode[HttpCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
47
|
+
HttpCode[HttpCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
48
|
+
HttpCode[HttpCode["Locked"] = 423] = "Locked";
|
|
49
|
+
HttpCode[HttpCode["FailedDependency"] = 424] = "FailedDependency";
|
|
50
|
+
HttpCode[HttpCode["TooEarly"] = 425] = "TooEarly";
|
|
51
|
+
HttpCode[HttpCode["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
52
|
+
HttpCode[HttpCode["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
53
|
+
HttpCode[HttpCode["TooManyRequests"] = 429] = "TooManyRequests";
|
|
54
|
+
HttpCode[HttpCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
55
|
+
HttpCode[HttpCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
56
|
+
HttpCode[HttpCode["InternalServerError"] = 500] = "InternalServerError";
|
|
57
|
+
HttpCode[HttpCode["NotImplemented"] = 501] = "NotImplemented";
|
|
58
|
+
HttpCode[HttpCode["BadGateway"] = 502] = "BadGateway";
|
|
59
|
+
HttpCode[HttpCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
60
|
+
HttpCode[HttpCode["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
61
|
+
HttpCode[HttpCode["HTTPVersionNotSupported"] = 505] = "HTTPVersionNotSupported";
|
|
62
|
+
HttpCode[HttpCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
63
|
+
HttpCode[HttpCode["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
64
|
+
HttpCode[HttpCode["LoopDetected"] = 508] = "LoopDetected";
|
|
65
|
+
HttpCode[HttpCode["NotExtended"] = 510] = "NotExtended";
|
|
66
|
+
HttpCode[HttpCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
67
|
+
})(HttpCode || (HttpCode = {}));
|
|
68
68
|
export const HttpStatusText = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
69
|
+
[HttpCode.Continue]: 'Continue',
|
|
70
|
+
[HttpCode.SwitchingProtocols]: 'Switching Protocols',
|
|
71
|
+
[HttpCode.Processing]: 'Processing',
|
|
72
|
+
[HttpCode.EarlyHints]: 'Early Hints',
|
|
73
|
+
[HttpCode.OK]: 'OK',
|
|
74
|
+
[HttpCode.Created]: 'Created',
|
|
75
|
+
[HttpCode.Accepted]: 'Accepted',
|
|
76
|
+
[HttpCode.NonAuthoritativeInformation]: 'Non-Authoritative Information',
|
|
77
|
+
[HttpCode.NoContent]: 'No Content',
|
|
78
|
+
[HttpCode.ResetContent]: 'Reset Content',
|
|
79
|
+
[HttpCode.PartialContent]: 'Partial Content',
|
|
80
|
+
[HttpCode.MultiStatus]: 'Multi-Status',
|
|
81
|
+
[HttpCode.AlreadyReported]: 'Already Reported',
|
|
82
|
+
[HttpCode.IMUsed]: 'IM Used',
|
|
83
|
+
[HttpCode.MultipleChoices]: 'Multiple Choices',
|
|
84
|
+
[HttpCode.MovedPermanently]: 'Moved Permanently',
|
|
85
|
+
[HttpCode.Found]: 'Found',
|
|
86
|
+
[HttpCode.SeeOther]: 'See Other',
|
|
87
|
+
[HttpCode.NotModified]: 'Not Modified',
|
|
88
|
+
[HttpCode.UseProxy]: 'Use Proxy',
|
|
89
|
+
[HttpCode.TemporaryRedirect]: 'Temporary Redirect',
|
|
90
|
+
[HttpCode.PermanentRedirect]: 'Permanent Redirect',
|
|
91
|
+
[HttpCode.BadRequest]: 'Bad Request',
|
|
92
|
+
[HttpCode.Unauthorized]: 'Unauthorized',
|
|
93
|
+
[HttpCode.PaymentRequired]: 'Payment Required',
|
|
94
|
+
[HttpCode.Forbidden]: 'Forbidden',
|
|
95
|
+
[HttpCode.NotFound]: 'Not Found',
|
|
96
|
+
[HttpCode.MethodNotAllowed]: 'Method Not Allowed',
|
|
97
|
+
[HttpCode.NotAcceptable]: 'Not Acceptable',
|
|
98
|
+
[HttpCode.ProxyAuthenticationRequired]: 'Proxy Authentication Required',
|
|
99
|
+
[HttpCode.RequestTimeout]: 'Request Timeout',
|
|
100
|
+
[HttpCode.Conflict]: 'Conflict',
|
|
101
|
+
[HttpCode.Gone]: 'Gone',
|
|
102
|
+
[HttpCode.LengthRequired]: 'Length Required',
|
|
103
|
+
[HttpCode.PreconditionFailed]: 'Precondition Failed',
|
|
104
|
+
[HttpCode.PayloadTooLarge]: 'Payload Too Large',
|
|
105
|
+
[HttpCode.URITooLong]: 'URI Too Long',
|
|
106
|
+
[HttpCode.UnsupportedMediaType]: 'Unsupported Media Type',
|
|
107
|
+
[HttpCode.RangeNotSatisfiable]: 'Range Not Satisfiable',
|
|
108
|
+
[HttpCode.ExpectationFailed]: 'Expectation Failed',
|
|
109
|
+
[HttpCode.ImATeapot]: "I'm a Teapot",
|
|
110
|
+
[HttpCode.MisdirectedRequest]: 'Misdirected Request',
|
|
111
|
+
[HttpCode.UnprocessableEntity]: 'Unprocessable Entity',
|
|
112
|
+
[HttpCode.Locked]: 'Locked',
|
|
113
|
+
[HttpCode.FailedDependency]: 'Failed Dependency',
|
|
114
|
+
[HttpCode.TooEarly]: 'Too Early',
|
|
115
|
+
[HttpCode.UpgradeRequired]: 'Upgrade Required',
|
|
116
|
+
[HttpCode.PreconditionRequired]: 'Precondition Required',
|
|
117
|
+
[HttpCode.TooManyRequests]: 'Too Many Requests',
|
|
118
|
+
[HttpCode.RequestHeaderFieldsTooLarge]: 'Request Header Fields Too Large',
|
|
119
|
+
[HttpCode.UnavailableForLegalReasons]: 'Unavailable For Legal Reasons',
|
|
120
|
+
[HttpCode.InternalServerError]: 'Internal Server Error',
|
|
121
|
+
[HttpCode.NotImplemented]: 'Not Implemented',
|
|
122
|
+
[HttpCode.BadGateway]: 'Bad Gateway',
|
|
123
|
+
[HttpCode.ServiceUnavailable]: 'Service Unavailable',
|
|
124
|
+
[HttpCode.GatewayTimeout]: 'Gateway Timeout',
|
|
125
|
+
[HttpCode.HTTPVersionNotSupported]: 'HTTP Version Not Supported',
|
|
126
|
+
[HttpCode.VariantAlsoNegotiates]: 'Variant Also Negotiates',
|
|
127
|
+
[HttpCode.InsufficientStorage]: 'Insufficient Storage',
|
|
128
|
+
[HttpCode.LoopDetected]: 'Loop Detected',
|
|
129
|
+
[HttpCode.NotExtended]: 'Not Extended',
|
|
130
|
+
[HttpCode.NetworkAuthenticationRequired]: 'Network Authentication Required',
|
|
131
131
|
};
|
|
132
132
|
export const HttpCodeMap = {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
[ErrorCode.ValidationError]: HttpCode.BadRequest,
|
|
134
|
+
[ErrorCode.BadRequest]: HttpCode.BadRequest,
|
|
135
|
+
[ErrorCode.NotFound]: HttpCode.NotFound,
|
|
136
|
+
[ErrorCode.Forbidden]: HttpCode.Forbidden,
|
|
137
|
+
[ErrorCode.Unauthorized]: HttpCode.Unauthorized,
|
|
138
|
+
[ErrorCode.InternalServerError]: HttpCode.InternalServerError,
|
|
139
|
+
[ErrorCode.NotAcceptable]: HttpCode.NotAcceptable,
|
|
140
|
+
[ErrorCode.RequestTimeout]: HttpCode.RequestTimeout,
|
|
141
|
+
[ErrorCode.GatewayTimeout]: HttpCode.GatewayTimeout,
|
|
142
|
+
[ErrorCode.ServiceUnavailable]: HttpCode.ServiceUnavailable,
|
|
143
|
+
[ErrorCode.ClientRequestError]: HttpCode.BadRequest,
|
|
144
|
+
[ErrorCode.ConnectionError]: HttpCode.NotAcceptable,
|
|
145
145
|
};
|
|
146
|
-
export const AllowedHttpMethod = createMetadataKey(
|
|
147
|
-
|
|
148
|
-
//# sourceMappingURL=http.js.map
|
|
146
|
+
export const AllowedHttpMethod = createMetadataKey('http:method');
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type LazyInjectable, Scope } from '@nmtjs/core';
|
|
2
|
+
export declare const WsTransportInjectables: {
|
|
3
|
+
readonly connectionData: LazyInjectable<Readonly<{
|
|
4
|
+
url: string;
|
|
5
|
+
origin: URL | null;
|
|
6
|
+
method: string;
|
|
7
|
+
headers: Headers;
|
|
8
|
+
querystring: string;
|
|
9
|
+
query: URLSearchParams;
|
|
10
|
+
remoteAddress: string;
|
|
11
|
+
proxiedRemoteAddress: string;
|
|
12
|
+
}>, Scope.Connection>;
|
|
13
|
+
readonly httpResponseHeaders: LazyInjectable<Headers, Scope.Call>;
|
|
14
|
+
};
|
package/dist/injectables.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { createLazyInjectable, Scope } from
|
|
2
|
-
import { ProtocolInjectables } from
|
|
1
|
+
import { createLazyInjectable, Scope } from '@nmtjs/core';
|
|
2
|
+
import { ProtocolInjectables } from '@nmtjs/protocol/server';
|
|
3
3
|
const connectionData = ProtocolInjectables.connectionData;
|
|
4
4
|
const httpResponseHeaders = createLazyInjectable(Scope.Call);
|
|
5
5
|
export const WsTransportInjectables = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
connectionData,
|
|
7
|
+
httpResponseHeaders,
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=injectables.js.map
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type HttpRequest, type HttpResponse, type TemplatedApp } from 'uWebSockets.js';
|
|
2
|
+
import { ClientMessageType, type ServerMessageType } from '@nmtjs/protocol';
|
|
3
|
+
import { Connection, type Transport, type TransportPluginContext } from '@nmtjs/protocol/server';
|
|
4
|
+
import type { WsConnectionData, WsTransportOptions, WsTransportSocket } from './types.ts';
|
|
5
|
+
export declare class WsTransportServer implements Transport<WsConnectionData> {
|
|
6
|
+
protected readonly context: TransportPluginContext;
|
|
7
|
+
protected readonly options: WsTransportOptions;
|
|
8
|
+
protected server: TemplatedApp;
|
|
9
|
+
protected clients: Map<string, WsTransportSocket>;
|
|
10
|
+
constructor(context: TransportPluginContext, options: WsTransportOptions);
|
|
11
|
+
send(connection: Connection<WsConnectionData>, messageType: ServerMessageType, buffer: ArrayBuffer): void;
|
|
12
|
+
start(): Promise<void>;
|
|
13
|
+
stop(): Promise<void>;
|
|
14
|
+
protected httpHandler(res: HttpResponse, req: HttpRequest): Promise<undefined>;
|
|
15
|
+
protected get protocol(): import("@nmtjs/protocol/server").Protocol;
|
|
16
|
+
protected get logger(): import("@nmtjs/core").Logger;
|
|
17
|
+
protected logError(cause: any, message?: string): Promise<void>;
|
|
18
|
+
protected applyCors(res: HttpResponse, req: HttpRequest): void;
|
|
19
|
+
protected [ClientMessageType.Rpc](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
20
|
+
protected [ClientMessageType.RpcAbort](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
21
|
+
protected [ClientMessageType.RpcStreamAbort](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
22
|
+
protected [ClientMessageType.ClientStreamPush](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
23
|
+
protected [ClientMessageType.ClientStreamEnd](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
24
|
+
protected [ClientMessageType.ClientStreamAbort](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
25
|
+
protected [ClientMessageType.ServerStreamPull](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
26
|
+
protected [ClientMessageType.ServerStreamAbort](ws: WsTransportSocket, buffer: ArrayBuffer): void;
|
|
27
|
+
}
|