@twin.org/api-models 0.0.2-next.2 → 0.0.2-next.5
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/types/index.d.ts +2 -0
- package/dist/types/models/protocol/IHttpRequestContext.d.ts +4 -0
- package/dist/types/models/protocol/ISocketRequestContext.d.ts +10 -0
- package/dist/types/models/protocol/ISocketServerRequest.d.ts +10 -0
- package/dist/types/models/routes/ISocketRoute.d.ts +18 -2
- package/dist/types/models/server/IBaseRouteProcessor.d.ts +7 -5
- package/dist/types/models/server/IRestRouteProcessor.d.ts +2 -1
- package/dist/types/models/server/ISocketRouteProcessor.d.ts +12 -15
- package/docs/changelog.md +26 -0
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IBaseRouteProcessor.md +21 -5
- package/docs/reference/interfaces/IHttpRequestContext.md +12 -0
- package/docs/reference/interfaces/IHttpServerRequest.md +4 -0
- package/docs/reference/interfaces/IRestRouteProcessor.md +21 -3
- package/docs/reference/interfaces/ISocketRequestContext.md +79 -0
- package/docs/reference/interfaces/ISocketRoute.md +43 -3
- package/docs/reference/interfaces/ISocketRouteProcessor.md +40 -18
- package/docs/reference/interfaces/ISocketServerRequest.md +93 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export * from "./models/protocol/IHttpRequestPathParams";
|
|
|
15
15
|
export * from "./models/protocol/IHttpRequestQuery";
|
|
16
16
|
export * from "./models/protocol/IHttpResponse";
|
|
17
17
|
export * from "./models/protocol/IHttpServerRequest";
|
|
18
|
+
export * from "./models/protocol/ISocketRequestContext";
|
|
19
|
+
export * from "./models/protocol/ISocketServerRequest";
|
|
18
20
|
export * from "./models/requests/INoContentRequest";
|
|
19
21
|
export * from "./models/responses/errors/IBadRequestResponse";
|
|
20
22
|
export * from "./models/responses/errors/IConflictResponse";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IHttpServerRequest } from "./IHttpServerRequest";
|
|
2
|
+
/**
|
|
3
|
+
* Model for the standard parameters for an http request.
|
|
4
|
+
*/
|
|
5
|
+
export interface ISocketServerRequest<T = any> extends IHttpServerRequest<T> {
|
|
6
|
+
/**
|
|
7
|
+
* The socket id.
|
|
8
|
+
*/
|
|
9
|
+
socketId: string;
|
|
10
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IBaseRoute } from "./IBaseRoute";
|
|
2
2
|
import type { IHttpRequest } from "../protocol/IHttpRequest";
|
|
3
|
-
import type { IHttpRequestContext } from "../protocol/IHttpRequestContext";
|
|
4
3
|
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
4
|
+
import type { ISocketRequestContext } from "../protocol/ISocketRequestContext";
|
|
5
5
|
/**
|
|
6
6
|
* Interface which defines a socket route.
|
|
7
7
|
*/
|
|
@@ -13,7 +13,7 @@ export interface ISocketRoute<T extends IHttpRequest = any, U extends IHttpRespo
|
|
|
13
13
|
/**
|
|
14
14
|
* The request context.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
socketRequestContext: ISocketRequestContext,
|
|
17
17
|
/**
|
|
18
18
|
* The request object.
|
|
19
19
|
*/
|
|
@@ -22,4 +22,20 @@ export interface ISocketRoute<T extends IHttpRequest = any, U extends IHttpRespo
|
|
|
22
22
|
* The function to emit an event.
|
|
23
23
|
*/
|
|
24
24
|
emit: (event: string, response: U) => Promise<void>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* The connected handler.
|
|
27
|
+
*/
|
|
28
|
+
connected?: (
|
|
29
|
+
/**
|
|
30
|
+
* The request context.
|
|
31
|
+
*/
|
|
32
|
+
socketRequestContext: ISocketRequestContext) => void;
|
|
33
|
+
/**
|
|
34
|
+
* The disconnected handler.
|
|
35
|
+
*/
|
|
36
|
+
disconnected?: (
|
|
37
|
+
/**
|
|
38
|
+
* The request context.
|
|
39
|
+
*/
|
|
40
|
+
socketRequestContext: ISocketRequestContext) => void;
|
|
25
41
|
}
|
|
@@ -6,7 +6,7 @@ import type { IBaseRoute } from "../routes/IBaseRoute";
|
|
|
6
6
|
/**
|
|
7
7
|
* The definition for a base processor for handling REST routes.
|
|
8
8
|
*/
|
|
9
|
-
export interface IBaseRouteProcessor<T = IBaseRoute> extends IComponent {
|
|
9
|
+
export interface IBaseRouteProcessor<T = IBaseRoute, R = IHttpServerRequest> extends IComponent {
|
|
10
10
|
/**
|
|
11
11
|
* Pre process the REST request for the specified route.
|
|
12
12
|
* @param request The request to handle.
|
|
@@ -14,11 +14,12 @@ export interface IBaseRouteProcessor<T = IBaseRoute> extends IComponent {
|
|
|
14
14
|
* @param route The route being requested, if a matching one was found.
|
|
15
15
|
* @param requestIdentity The identity context for the request.
|
|
16
16
|
* @param processorState The state handed through the processors.
|
|
17
|
+
* @param loggingComponentType The logging component type for the request.
|
|
17
18
|
* @returns Promise that resolves when the request is processed.
|
|
18
19
|
*/
|
|
19
|
-
pre?(request:
|
|
20
|
+
pre?(request: R, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
20
21
|
[id: string]: unknown;
|
|
21
|
-
}): Promise<void>;
|
|
22
|
+
}, loggingComponentType?: string): Promise<void>;
|
|
22
23
|
/**
|
|
23
24
|
* Post process the REST request for the specified route.
|
|
24
25
|
* @param request The request to handle.
|
|
@@ -26,9 +27,10 @@ export interface IBaseRouteProcessor<T = IBaseRoute> extends IComponent {
|
|
|
26
27
|
* @param route The route being requested, if a matching one was found.
|
|
27
28
|
* @param requestIdentity The identity context for the request.
|
|
28
29
|
* @param processorState The state handed through the processors.
|
|
30
|
+
* @param loggingComponentType The logging component type for the request.
|
|
29
31
|
* @returns Promise that resolves when the request is processed.
|
|
30
32
|
*/
|
|
31
|
-
post?(request:
|
|
33
|
+
post?(request: R, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
32
34
|
[id: string]: unknown;
|
|
33
|
-
}): Promise<void>;
|
|
35
|
+
}, loggingComponentType?: string): Promise<void>;
|
|
34
36
|
}
|
|
@@ -14,9 +14,10 @@ export interface IRestRouteProcessor extends IBaseRouteProcessor<IRestRoute> {
|
|
|
14
14
|
* @param route The route being requested, if a matching one was found.
|
|
15
15
|
* @param requestIdentity The identity context for the request.
|
|
16
16
|
* @param processorState The state handed through the processors.
|
|
17
|
+
* @param loggingComponentType The logging component type for the request.
|
|
17
18
|
* @returns Promise that resolves when the request is processed.
|
|
18
19
|
*/
|
|
19
20
|
process?(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
20
21
|
[id: string]: unknown;
|
|
21
|
-
}): Promise<void>;
|
|
22
|
+
}, loggingComponentType?: string): Promise<void>;
|
|
22
23
|
}
|
|
@@ -1,43 +1,40 @@
|
|
|
1
1
|
import type { IBaseRouteProcessor } from "./IBaseRouteProcessor";
|
|
2
2
|
import type { IHttpRequestIdentity } from "../protocol/IHttpRequestIdentity";
|
|
3
3
|
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ISocketServerRequest } from "../protocol/ISocketServerRequest";
|
|
5
5
|
import type { ISocketRoute } from "../routes/ISocketRoute";
|
|
6
6
|
/**
|
|
7
7
|
* The definition for a processor for handling socket routes.
|
|
8
8
|
*/
|
|
9
|
-
export interface ISocketRouteProcessor extends IBaseRouteProcessor<ISocketRoute> {
|
|
9
|
+
export interface ISocketRouteProcessor extends IBaseRouteProcessor<ISocketRoute, ISocketServerRequest> {
|
|
10
10
|
/**
|
|
11
11
|
* Process the connected event.
|
|
12
|
-
* @param request The request
|
|
12
|
+
* @param request The server request object containing the socket id and other parameters.
|
|
13
13
|
* @param route The route being requested, if a matching one was found.
|
|
14
|
-
* @param
|
|
14
|
+
* @param loggingComponentType The logging component type for the request.
|
|
15
15
|
* @returns Promise that resolves when the request is processed.
|
|
16
16
|
*/
|
|
17
|
-
connected?(request:
|
|
18
|
-
[id: string]: unknown;
|
|
19
|
-
}): Promise<void>;
|
|
17
|
+
connected?(request: ISocketServerRequest, route: ISocketRoute | undefined, loggingComponentType?: string): Promise<void>;
|
|
20
18
|
/**
|
|
21
19
|
* Process the disconnected event.
|
|
22
|
-
* @param request The request
|
|
20
|
+
* @param request The server request object containing the socket id and other parameters.
|
|
23
21
|
* @param route The route being requested, if a matching one was found.
|
|
24
|
-
* @param
|
|
22
|
+
* @param loggingComponentType The logging component type for the request.
|
|
25
23
|
* @returns Promise that resolves when the request is processed.
|
|
26
24
|
*/
|
|
27
|
-
disconnected?(request:
|
|
28
|
-
[id: string]: unknown;
|
|
29
|
-
}): Promise<void>;
|
|
25
|
+
disconnected?(request: ISocketServerRequest, route: ISocketRoute | undefined, loggingComponentType?: string): Promise<void>;
|
|
30
26
|
/**
|
|
31
27
|
* Process the REST request for the specified route.
|
|
32
|
-
* @param request The request
|
|
28
|
+
* @param request The server request object containing the socket id and other parameters.
|
|
33
29
|
* @param response The response data to send if any.
|
|
34
30
|
* @param route The route being requested, if a matching one was found.
|
|
35
31
|
* @param requestIdentity The identity context for the request.
|
|
36
32
|
* @param processorState The state handed through the processors.
|
|
37
33
|
* @param responseEmitter The function to emit a response.
|
|
34
|
+
* @param loggingComponentType The logging component type for the request.
|
|
38
35
|
* @returns Promise that resolves when the request is processed.
|
|
39
36
|
*/
|
|
40
|
-
process?(request:
|
|
37
|
+
process?(request: ISocketServerRequest, response: IHttpResponse, route: ISocketRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
41
38
|
[id: string]: unknown;
|
|
42
|
-
}, responseEmitter: (topic: string, response: IHttpResponse) => Promise<void
|
|
39
|
+
}, responseEmitter: (topic: string, response: IHttpResponse) => Promise<void>, loggingComponentType?: string): Promise<void>;
|
|
43
40
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @twin.org/api-models - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.5](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.4...api-models-v0.0.2-next.5) (2025-07-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
|
|
9
|
+
* add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
|
|
10
|
+
* update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
11
|
+
* use new includeStackTrace flag for toJsonObject ([6452b15](https://github.com/twinfoundation/api/commit/6452b153af786eee14b21152420f8a2578b70593))
|
|
12
|
+
* use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
13
|
+
* validationError mapped to http status badrequest ([adc5eb1](https://github.com/twinfoundation/api/commit/adc5eb11d987abb0ab9f7e0dc8e1fdae207e436e))
|
|
14
|
+
|
|
15
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.3...api-models-v0.0.2-next.4) (2025-07-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
|
|
21
|
+
|
|
22
|
+
## [0.0.2-next.3](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.2...api-models-v0.0.2-next.3) (2025-07-24)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
|
|
28
|
+
|
|
3
29
|
## [0.0.2-next.2](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.1...api-models-v0.0.2-next.2) (2025-07-17)
|
|
4
30
|
|
|
5
31
|
|
package/docs/reference/index.md
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
- [IHttpRequestQuery](interfaces/IHttpRequestQuery.md)
|
|
20
20
|
- [IHttpResponse](interfaces/IHttpResponse.md)
|
|
21
21
|
- [IHttpServerRequest](interfaces/IHttpServerRequest.md)
|
|
22
|
+
- [ISocketRequestContext](interfaces/ISocketRequestContext.md)
|
|
23
|
+
- [ISocketServerRequest](interfaces/ISocketServerRequest.md)
|
|
22
24
|
- [INoContentRequest](interfaces/INoContentRequest.md)
|
|
23
25
|
- [IBadRequestResponse](interfaces/IBadRequestResponse.md)
|
|
24
26
|
- [IConflictResponse](interfaces/IConflictResponse.md)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Interface: IBaseRouteProcessor\<T\>
|
|
1
|
+
# Interface: IBaseRouteProcessor\<T, R\>
|
|
2
2
|
|
|
3
3
|
The definition for a base processor for handling REST routes.
|
|
4
4
|
|
|
@@ -17,11 +17,15 @@ The definition for a base processor for handling REST routes.
|
|
|
17
17
|
|
|
18
18
|
`T` = [`IBaseRoute`](IBaseRoute.md)
|
|
19
19
|
|
|
20
|
+
### R
|
|
21
|
+
|
|
22
|
+
`R` = [`IHttpServerRequest`](IHttpServerRequest.md)
|
|
23
|
+
|
|
20
24
|
## Methods
|
|
21
25
|
|
|
22
26
|
### pre()?
|
|
23
27
|
|
|
24
|
-
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
28
|
+
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
25
29
|
|
|
26
30
|
Pre process the REST request for the specified route.
|
|
27
31
|
|
|
@@ -29,7 +33,7 @@ Pre process the REST request for the specified route.
|
|
|
29
33
|
|
|
30
34
|
##### request
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
`R`
|
|
33
37
|
|
|
34
38
|
The request to handle.
|
|
35
39
|
|
|
@@ -55,6 +59,12 @@ The identity context for the request.
|
|
|
55
59
|
|
|
56
60
|
The state handed through the processors.
|
|
57
61
|
|
|
62
|
+
##### loggingComponentType?
|
|
63
|
+
|
|
64
|
+
`string`
|
|
65
|
+
|
|
66
|
+
The logging component type for the request.
|
|
67
|
+
|
|
58
68
|
#### Returns
|
|
59
69
|
|
|
60
70
|
`Promise`\<`void`\>
|
|
@@ -65,7 +75,7 @@ Promise that resolves when the request is processed.
|
|
|
65
75
|
|
|
66
76
|
### post()?
|
|
67
77
|
|
|
68
|
-
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
78
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
69
79
|
|
|
70
80
|
Post process the REST request for the specified route.
|
|
71
81
|
|
|
@@ -73,7 +83,7 @@ Post process the REST request for the specified route.
|
|
|
73
83
|
|
|
74
84
|
##### request
|
|
75
85
|
|
|
76
|
-
|
|
86
|
+
`R`
|
|
77
87
|
|
|
78
88
|
The request to handle.
|
|
79
89
|
|
|
@@ -99,6 +109,12 @@ The identity context for the request.
|
|
|
99
109
|
|
|
100
110
|
The state handed through the processors.
|
|
101
111
|
|
|
112
|
+
##### loggingComponentType?
|
|
113
|
+
|
|
114
|
+
`string`
|
|
115
|
+
|
|
116
|
+
The logging component type for the request.
|
|
117
|
+
|
|
102
118
|
#### Returns
|
|
103
119
|
|
|
104
120
|
`Promise`\<`void`\>
|
|
@@ -6,6 +6,10 @@ Context data from the HTTP request.
|
|
|
6
6
|
|
|
7
7
|
- [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
8
8
|
|
|
9
|
+
## Extended by
|
|
10
|
+
|
|
11
|
+
- [`ISocketRequestContext`](ISocketRequestContext.md)
|
|
12
|
+
|
|
9
13
|
## Properties
|
|
10
14
|
|
|
11
15
|
### serverRequest
|
|
@@ -28,6 +32,14 @@ The state handed through the processors.
|
|
|
28
32
|
|
|
29
33
|
***
|
|
30
34
|
|
|
35
|
+
### loggingComponentType?
|
|
36
|
+
|
|
37
|
+
> `optional` **loggingComponentType**: `string`
|
|
38
|
+
|
|
39
|
+
Logging component type for the request.
|
|
40
|
+
|
|
41
|
+
***
|
|
42
|
+
|
|
31
43
|
### nodeIdentity?
|
|
32
44
|
|
|
33
45
|
> `optional` **nodeIdentity**: `string`
|
|
@@ -10,7 +10,7 @@ The definition for a processor for handling REST routes.
|
|
|
10
10
|
|
|
11
11
|
### pre()?
|
|
12
12
|
|
|
13
|
-
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
13
|
+
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
14
14
|
|
|
15
15
|
Pre process the REST request for the specified route.
|
|
16
16
|
|
|
@@ -44,6 +44,12 @@ The identity context for the request.
|
|
|
44
44
|
|
|
45
45
|
The state handed through the processors.
|
|
46
46
|
|
|
47
|
+
##### loggingComponentType?
|
|
48
|
+
|
|
49
|
+
`string`
|
|
50
|
+
|
|
51
|
+
The logging component type for the request.
|
|
52
|
+
|
|
47
53
|
#### Returns
|
|
48
54
|
|
|
49
55
|
`Promise`\<`void`\>
|
|
@@ -58,7 +64,7 @@ Promise that resolves when the request is processed.
|
|
|
58
64
|
|
|
59
65
|
### post()?
|
|
60
66
|
|
|
61
|
-
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
67
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
62
68
|
|
|
63
69
|
Post process the REST request for the specified route.
|
|
64
70
|
|
|
@@ -92,6 +98,12 @@ The identity context for the request.
|
|
|
92
98
|
|
|
93
99
|
The state handed through the processors.
|
|
94
100
|
|
|
101
|
+
##### loggingComponentType?
|
|
102
|
+
|
|
103
|
+
`string`
|
|
104
|
+
|
|
105
|
+
The logging component type for the request.
|
|
106
|
+
|
|
95
107
|
#### Returns
|
|
96
108
|
|
|
97
109
|
`Promise`\<`void`\>
|
|
@@ -106,7 +118,7 @@ Promise that resolves when the request is processed.
|
|
|
106
118
|
|
|
107
119
|
### process()?
|
|
108
120
|
|
|
109
|
-
> `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
121
|
+
> `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
110
122
|
|
|
111
123
|
Process the REST request for the specified route.
|
|
112
124
|
|
|
@@ -140,6 +152,12 @@ The identity context for the request.
|
|
|
140
152
|
|
|
141
153
|
The state handed through the processors.
|
|
142
154
|
|
|
155
|
+
##### loggingComponentType?
|
|
156
|
+
|
|
157
|
+
`string`
|
|
158
|
+
|
|
159
|
+
The logging component type for the request.
|
|
160
|
+
|
|
143
161
|
#### Returns
|
|
144
162
|
|
|
145
163
|
`Promise`\<`void`\>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Interface: ISocketRequestContext
|
|
2
|
+
|
|
3
|
+
Context data from the socket request.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- [`IHttpRequestContext`](IHttpRequestContext.md)
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
### serverRequest
|
|
12
|
+
|
|
13
|
+
> **serverRequest**: [`IHttpServerRequest`](IHttpServerRequest.md)
|
|
14
|
+
|
|
15
|
+
The raw HTTP request.
|
|
16
|
+
|
|
17
|
+
#### Inherited from
|
|
18
|
+
|
|
19
|
+
[`IHttpRequestContext`](IHttpRequestContext.md).[`serverRequest`](IHttpRequestContext.md#serverrequest)
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### processorState
|
|
24
|
+
|
|
25
|
+
> **processorState**: `object`
|
|
26
|
+
|
|
27
|
+
The state handed through the processors.
|
|
28
|
+
|
|
29
|
+
#### Index Signature
|
|
30
|
+
|
|
31
|
+
\[`id`: `string`\]: `unknown`
|
|
32
|
+
|
|
33
|
+
#### Inherited from
|
|
34
|
+
|
|
35
|
+
[`IHttpRequestContext`](IHttpRequestContext.md).[`processorState`](IHttpRequestContext.md#processorstate)
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### loggingComponentType?
|
|
40
|
+
|
|
41
|
+
> `optional` **loggingComponentType**: `string`
|
|
42
|
+
|
|
43
|
+
Logging component type for the request.
|
|
44
|
+
|
|
45
|
+
#### Inherited from
|
|
46
|
+
|
|
47
|
+
[`IHttpRequestContext`](IHttpRequestContext.md).[`loggingComponentType`](IHttpRequestContext.md#loggingcomponenttype)
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### nodeIdentity?
|
|
52
|
+
|
|
53
|
+
> `optional` **nodeIdentity**: `string`
|
|
54
|
+
|
|
55
|
+
The identity of the node the request is being performed on.
|
|
56
|
+
|
|
57
|
+
#### Inherited from
|
|
58
|
+
|
|
59
|
+
[`IHttpRequestContext`](IHttpRequestContext.md).[`nodeIdentity`](IHttpRequestContext.md#nodeidentity)
|
|
60
|
+
|
|
61
|
+
***
|
|
62
|
+
|
|
63
|
+
### userIdentity?
|
|
64
|
+
|
|
65
|
+
> `optional` **userIdentity**: `string`
|
|
66
|
+
|
|
67
|
+
The identity of the requestor if there is an authenticated user.
|
|
68
|
+
|
|
69
|
+
#### Inherited from
|
|
70
|
+
|
|
71
|
+
[`IHttpRequestContext`](IHttpRequestContext.md).[`userIdentity`](IHttpRequestContext.md#useridentity)
|
|
72
|
+
|
|
73
|
+
***
|
|
74
|
+
|
|
75
|
+
### socketId
|
|
76
|
+
|
|
77
|
+
> **socketId**: `string`
|
|
78
|
+
|
|
79
|
+
The id of the socket.
|
|
@@ -56,15 +56,15 @@ Skips the authentication for this route.
|
|
|
56
56
|
|
|
57
57
|
### handler()
|
|
58
58
|
|
|
59
|
-
> **handler**: (`
|
|
59
|
+
> **handler**: (`socketRequestContext`, `request`, `emit`) => `void`
|
|
60
60
|
|
|
61
61
|
The handler module.
|
|
62
62
|
|
|
63
63
|
#### Parameters
|
|
64
64
|
|
|
65
|
-
#####
|
|
65
|
+
##### socketRequestContext
|
|
66
66
|
|
|
67
|
-
[`
|
|
67
|
+
[`ISocketRequestContext`](ISocketRequestContext.md)
|
|
68
68
|
|
|
69
69
|
The request context.
|
|
70
70
|
|
|
@@ -83,3 +83,43 @@ The function to emit an event.
|
|
|
83
83
|
#### Returns
|
|
84
84
|
|
|
85
85
|
`void`
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### connected()?
|
|
90
|
+
|
|
91
|
+
> `optional` **connected**: (`socketRequestContext`) => `void`
|
|
92
|
+
|
|
93
|
+
The connected handler.
|
|
94
|
+
|
|
95
|
+
#### Parameters
|
|
96
|
+
|
|
97
|
+
##### socketRequestContext
|
|
98
|
+
|
|
99
|
+
[`ISocketRequestContext`](ISocketRequestContext.md)
|
|
100
|
+
|
|
101
|
+
The request context.
|
|
102
|
+
|
|
103
|
+
#### Returns
|
|
104
|
+
|
|
105
|
+
`void`
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### disconnected()?
|
|
110
|
+
|
|
111
|
+
> `optional` **disconnected**: (`socketRequestContext`) => `void`
|
|
112
|
+
|
|
113
|
+
The disconnected handler.
|
|
114
|
+
|
|
115
|
+
#### Parameters
|
|
116
|
+
|
|
117
|
+
##### socketRequestContext
|
|
118
|
+
|
|
119
|
+
[`ISocketRequestContext`](ISocketRequestContext.md)
|
|
120
|
+
|
|
121
|
+
The request context.
|
|
122
|
+
|
|
123
|
+
#### Returns
|
|
124
|
+
|
|
125
|
+
`void`
|
|
@@ -4,13 +4,13 @@ The definition for a processor for handling socket routes.
|
|
|
4
4
|
|
|
5
5
|
## Extends
|
|
6
6
|
|
|
7
|
-
- [`IBaseRouteProcessor`](IBaseRouteProcessor.md)\<[`ISocketRoute`](ISocketRoute.md)\>
|
|
7
|
+
- [`IBaseRouteProcessor`](IBaseRouteProcessor.md)\<[`ISocketRoute`](ISocketRoute.md), [`ISocketServerRequest`](ISocketServerRequest.md)\>
|
|
8
8
|
|
|
9
9
|
## Methods
|
|
10
10
|
|
|
11
11
|
### pre()?
|
|
12
12
|
|
|
13
|
-
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
13
|
+
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
14
14
|
|
|
15
15
|
Pre process the REST request for the specified route.
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ Pre process the REST request for the specified route.
|
|
|
18
18
|
|
|
19
19
|
##### request
|
|
20
20
|
|
|
21
|
-
[`
|
|
21
|
+
[`ISocketServerRequest`](ISocketServerRequest.md)
|
|
22
22
|
|
|
23
23
|
The request to handle.
|
|
24
24
|
|
|
@@ -44,6 +44,12 @@ The identity context for the request.
|
|
|
44
44
|
|
|
45
45
|
The state handed through the processors.
|
|
46
46
|
|
|
47
|
+
##### loggingComponentType?
|
|
48
|
+
|
|
49
|
+
`string`
|
|
50
|
+
|
|
51
|
+
The logging component type for the request.
|
|
52
|
+
|
|
47
53
|
#### Returns
|
|
48
54
|
|
|
49
55
|
`Promise`\<`void`\>
|
|
@@ -58,7 +64,7 @@ Promise that resolves when the request is processed.
|
|
|
58
64
|
|
|
59
65
|
### post()?
|
|
60
66
|
|
|
61
|
-
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
67
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
62
68
|
|
|
63
69
|
Post process the REST request for the specified route.
|
|
64
70
|
|
|
@@ -66,7 +72,7 @@ Post process the REST request for the specified route.
|
|
|
66
72
|
|
|
67
73
|
##### request
|
|
68
74
|
|
|
69
|
-
[`
|
|
75
|
+
[`ISocketServerRequest`](ISocketServerRequest.md)
|
|
70
76
|
|
|
71
77
|
The request to handle.
|
|
72
78
|
|
|
@@ -92,6 +98,12 @@ The identity context for the request.
|
|
|
92
98
|
|
|
93
99
|
The state handed through the processors.
|
|
94
100
|
|
|
101
|
+
##### loggingComponentType?
|
|
102
|
+
|
|
103
|
+
`string`
|
|
104
|
+
|
|
105
|
+
The logging component type for the request.
|
|
106
|
+
|
|
95
107
|
#### Returns
|
|
96
108
|
|
|
97
109
|
`Promise`\<`void`\>
|
|
@@ -106,7 +118,7 @@ Promise that resolves when the request is processed.
|
|
|
106
118
|
|
|
107
119
|
### connected()?
|
|
108
120
|
|
|
109
|
-
> `optional` **connected**(`request`, `route`, `
|
|
121
|
+
> `optional` **connected**(`request`, `route`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
110
122
|
|
|
111
123
|
Process the connected event.
|
|
112
124
|
|
|
@@ -114,9 +126,9 @@ Process the connected event.
|
|
|
114
126
|
|
|
115
127
|
##### request
|
|
116
128
|
|
|
117
|
-
[`
|
|
129
|
+
[`ISocketServerRequest`](ISocketServerRequest.md)
|
|
118
130
|
|
|
119
|
-
The request
|
|
131
|
+
The server request object containing the socket id and other parameters.
|
|
120
132
|
|
|
121
133
|
##### route
|
|
122
134
|
|
|
@@ -124,9 +136,11 @@ The route being requested, if a matching one was found.
|
|
|
124
136
|
|
|
125
137
|
`undefined` | [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
126
138
|
|
|
127
|
-
#####
|
|
139
|
+
##### loggingComponentType?
|
|
128
140
|
|
|
129
|
-
|
|
141
|
+
`string`
|
|
142
|
+
|
|
143
|
+
The logging component type for the request.
|
|
130
144
|
|
|
131
145
|
#### Returns
|
|
132
146
|
|
|
@@ -138,7 +152,7 @@ Promise that resolves when the request is processed.
|
|
|
138
152
|
|
|
139
153
|
### disconnected()?
|
|
140
154
|
|
|
141
|
-
> `optional` **disconnected**(`request`, `route`, `
|
|
155
|
+
> `optional` **disconnected**(`request`, `route`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
142
156
|
|
|
143
157
|
Process the disconnected event.
|
|
144
158
|
|
|
@@ -146,9 +160,9 @@ Process the disconnected event.
|
|
|
146
160
|
|
|
147
161
|
##### request
|
|
148
162
|
|
|
149
|
-
[`
|
|
163
|
+
[`ISocketServerRequest`](ISocketServerRequest.md)
|
|
150
164
|
|
|
151
|
-
The request
|
|
165
|
+
The server request object containing the socket id and other parameters.
|
|
152
166
|
|
|
153
167
|
##### route
|
|
154
168
|
|
|
@@ -156,9 +170,11 @@ The route being requested, if a matching one was found.
|
|
|
156
170
|
|
|
157
171
|
`undefined` | [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
158
172
|
|
|
159
|
-
#####
|
|
173
|
+
##### loggingComponentType?
|
|
160
174
|
|
|
161
|
-
|
|
175
|
+
`string`
|
|
176
|
+
|
|
177
|
+
The logging component type for the request.
|
|
162
178
|
|
|
163
179
|
#### Returns
|
|
164
180
|
|
|
@@ -170,7 +186,7 @@ Promise that resolves when the request is processed.
|
|
|
170
186
|
|
|
171
187
|
### process()?
|
|
172
188
|
|
|
173
|
-
> `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `responseEmitter`): `Promise`\<`void`\>
|
|
189
|
+
> `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `responseEmitter`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
174
190
|
|
|
175
191
|
Process the REST request for the specified route.
|
|
176
192
|
|
|
@@ -178,9 +194,9 @@ Process the REST request for the specified route.
|
|
|
178
194
|
|
|
179
195
|
##### request
|
|
180
196
|
|
|
181
|
-
[`
|
|
197
|
+
[`ISocketServerRequest`](ISocketServerRequest.md)
|
|
182
198
|
|
|
183
|
-
The request
|
|
199
|
+
The server request object containing the socket id and other parameters.
|
|
184
200
|
|
|
185
201
|
##### response
|
|
186
202
|
|
|
@@ -210,6 +226,12 @@ The state handed through the processors.
|
|
|
210
226
|
|
|
211
227
|
The function to emit a response.
|
|
212
228
|
|
|
229
|
+
##### loggingComponentType?
|
|
230
|
+
|
|
231
|
+
`string`
|
|
232
|
+
|
|
233
|
+
The logging component type for the request.
|
|
234
|
+
|
|
213
235
|
#### Returns
|
|
214
236
|
|
|
215
237
|
`Promise`\<`void`\>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Interface: ISocketServerRequest\<T\>
|
|
2
|
+
|
|
3
|
+
Model for the standard parameters for an http request.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- [`IHttpServerRequest`](IHttpServerRequest.md)\<`T`\>
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### T
|
|
12
|
+
|
|
13
|
+
`T` = `any`
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### headers?
|
|
18
|
+
|
|
19
|
+
> `optional` **headers**: `IHttpHeaders`
|
|
20
|
+
|
|
21
|
+
Incoming Http Headers.
|
|
22
|
+
|
|
23
|
+
#### Inherited from
|
|
24
|
+
|
|
25
|
+
[`IHttpServerRequest`](IHttpServerRequest.md).[`headers`](IHttpServerRequest.md#headers)
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
29
|
+
### pathParams?
|
|
30
|
+
|
|
31
|
+
> `optional` **pathParams**: [`IHttpRequestPathParams`](IHttpRequestPathParams.md)
|
|
32
|
+
|
|
33
|
+
The path parameters.
|
|
34
|
+
|
|
35
|
+
#### Inherited from
|
|
36
|
+
|
|
37
|
+
[`IHttpServerRequest`](IHttpServerRequest.md).[`pathParams`](IHttpServerRequest.md#pathparams)
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### query?
|
|
42
|
+
|
|
43
|
+
> `optional` **query**: [`IHttpRequestQuery`](IHttpRequestQuery.md)
|
|
44
|
+
|
|
45
|
+
The query parameters.
|
|
46
|
+
|
|
47
|
+
#### Inherited from
|
|
48
|
+
|
|
49
|
+
[`IHttpServerRequest`](IHttpServerRequest.md).[`query`](IHttpServerRequest.md#query)
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### body?
|
|
54
|
+
|
|
55
|
+
> `optional` **body**: `T`
|
|
56
|
+
|
|
57
|
+
Data to return send as the body.
|
|
58
|
+
|
|
59
|
+
#### Inherited from
|
|
60
|
+
|
|
61
|
+
[`IHttpServerRequest`](IHttpServerRequest.md).[`body`](IHttpServerRequest.md#body)
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
65
|
+
### method?
|
|
66
|
+
|
|
67
|
+
> `optional` **method**: `HttpMethod`
|
|
68
|
+
|
|
69
|
+
The request method.
|
|
70
|
+
|
|
71
|
+
#### Inherited from
|
|
72
|
+
|
|
73
|
+
[`IHttpServerRequest`](IHttpServerRequest.md).[`method`](IHttpServerRequest.md#method)
|
|
74
|
+
|
|
75
|
+
***
|
|
76
|
+
|
|
77
|
+
### url?
|
|
78
|
+
|
|
79
|
+
> `optional` **url**: `string`
|
|
80
|
+
|
|
81
|
+
The request url.
|
|
82
|
+
|
|
83
|
+
#### Inherited from
|
|
84
|
+
|
|
85
|
+
[`IHttpServerRequest`](IHttpServerRequest.md).[`url`](IHttpServerRequest.md#url)
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### socketId
|
|
90
|
+
|
|
91
|
+
> **socketId**: `string`
|
|
92
|
+
|
|
93
|
+
The socket id.
|