@twin.org/api-models 0.0.1-next.11 → 0.0.1-next.13
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 +4 -1
- package/dist/types/models/config/IBaseSocketClientConfig.d.ts +4 -0
- package/dist/types/models/routes/ISocketRoute.d.ts +6 -8
- package/dist/types/models/server/IBaseRouteProcessor.d.ts +34 -0
- package/dist/types/models/server/IMimeTypeProcessor.d.ts +16 -0
- package/dist/types/models/server/IRestRouteProcessor.d.ts +22 -0
- package/dist/types/models/server/{IHttpRestRouteProcessor.d.ts → ISocketRouteProcessor.d.ts} +12 -15
- package/dist/types/models/server/IWebServer.d.ts +7 -3
- package/docs/changelog.md +1 -1
- package/docs/reference/index.md +4 -1
- package/docs/reference/interfaces/IBaseRouteProcessor.md +88 -0
- package/docs/reference/interfaces/IBaseSocketClientConfig.md +8 -0
- package/docs/reference/interfaces/IMimeTypeProcessor.md +37 -0
- package/docs/reference/interfaces/{IHttpRestRouteProcessor.md → IRestRouteProcessor.md} +16 -8
- package/docs/reference/interfaces/ISocketRoute.md +12 -10
- package/docs/reference/interfaces/ISocketRouteProcessor.md +183 -0
- package/docs/reference/interfaces/IWebServer.md +12 -4
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -34,7 +34,10 @@ export * from "./models/routes/IRestRouteResponseExample";
|
|
|
34
34
|
export * from "./models/routes/IRestRouteResponseOptions";
|
|
35
35
|
export * from "./models/routes/ISocketRoute";
|
|
36
36
|
export * from "./models/routes/ITag";
|
|
37
|
-
export * from "./models/server/
|
|
37
|
+
export * from "./models/server/IRestRouteProcessor";
|
|
38
|
+
export * from "./models/server/IMimeTypeProcessor";
|
|
39
|
+
export * from "./models/server/IBaseRouteProcessor";
|
|
40
|
+
export * from "./models/server/ISocketRouteProcessor";
|
|
38
41
|
export * from "./models/server/IWebServer";
|
|
39
42
|
export * from "./models/server/IWebServerOptions";
|
|
40
43
|
export * from "./models/services/healthStatus";
|
|
@@ -3,6 +3,10 @@ import type { IHttpHeaders } from "@twin.org/web";
|
|
|
3
3
|
* Definition for the configuration of a socket service.
|
|
4
4
|
*/
|
|
5
5
|
export interface IBaseSocketClientConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Base path for the socket service, defaults to /socket.
|
|
8
|
+
*/
|
|
9
|
+
basePath?: string;
|
|
6
10
|
/**
|
|
7
11
|
* The endpoint where the api is hosted.
|
|
8
12
|
*/
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { IBaseRoute } from "./IBaseRoute";
|
|
2
|
+
import type { IHttpRequest } from "../protocol/IHttpRequest";
|
|
2
3
|
import type { IHttpRequestContext } from "../protocol/IHttpRequestContext";
|
|
4
|
+
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
3
5
|
/**
|
|
4
6
|
* Interface which defines a socket route.
|
|
5
7
|
*/
|
|
6
|
-
export interface ISocketRoute extends IBaseRoute {
|
|
8
|
+
export interface ISocketRoute<T extends IHttpRequest = any, U extends IHttpResponse = any> extends IBaseRoute {
|
|
7
9
|
/**
|
|
8
10
|
* The handler module.
|
|
9
11
|
*/
|
|
@@ -12,16 +14,12 @@ export interface ISocketRoute extends IBaseRoute {
|
|
|
12
14
|
* The request context.
|
|
13
15
|
*/
|
|
14
16
|
httpRequestContext: IHttpRequestContext,
|
|
15
|
-
/**
|
|
16
|
-
* The id of the socket the request is arriving on.
|
|
17
|
-
*/
|
|
18
|
-
socketId: string,
|
|
19
17
|
/**
|
|
20
18
|
* The request object.
|
|
21
19
|
*/
|
|
22
|
-
request:
|
|
20
|
+
request: T,
|
|
23
21
|
/**
|
|
24
|
-
*
|
|
22
|
+
* The function to emit a message.
|
|
25
23
|
*/
|
|
26
|
-
|
|
24
|
+
emit: (response: U) => Promise<void>) => void;
|
|
27
25
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IHttpRequestIdentity } from "../protocol/IHttpRequestIdentity";
|
|
3
|
+
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
4
|
+
import type { IHttpServerRequest } from "../protocol/IHttpServerRequest";
|
|
5
|
+
import type { IBaseRoute } from "../routes/IBaseRoute";
|
|
6
|
+
/**
|
|
7
|
+
* The definition for a base processor for handling REST routes.
|
|
8
|
+
*/
|
|
9
|
+
export interface IBaseRouteProcessor<T = IBaseRoute> extends IComponent {
|
|
10
|
+
/**
|
|
11
|
+
* Pre process the REST request for the specified route.
|
|
12
|
+
* @param request The request to handle.
|
|
13
|
+
* @param response The response data to send if any.
|
|
14
|
+
* @param route The route being requested, if a matching one was found.
|
|
15
|
+
* @param requestIdentity The identity context for the request.
|
|
16
|
+
* @param processorState The state handed through the processors.
|
|
17
|
+
* @returns Promise that resolves when the request is processed.
|
|
18
|
+
*/
|
|
19
|
+
pre?(request: IHttpServerRequest, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
20
|
+
[id: string]: unknown;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Post process the REST request for the specified route.
|
|
24
|
+
* @param request The request to handle.
|
|
25
|
+
* @param response The response data to send if any.
|
|
26
|
+
* @param route The route being requested, if a matching one was found.
|
|
27
|
+
* @param requestIdentity The identity context for the request.
|
|
28
|
+
* @param processorState The state handed through the processors.
|
|
29
|
+
* @returns Promise that resolves when the request is processed.
|
|
30
|
+
*/
|
|
31
|
+
post?(request: IHttpServerRequest, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
32
|
+
[id: string]: unknown;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The definition for a handler for a specific MIME type.
|
|
3
|
+
*/
|
|
4
|
+
export interface IMimeTypeProcessor {
|
|
5
|
+
/**
|
|
6
|
+
* Get the MIME types that this handler can handle.
|
|
7
|
+
* @returns The MIME types that this handler can handle.
|
|
8
|
+
*/
|
|
9
|
+
getTypes(): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Handle content.
|
|
12
|
+
* @param body The body to process.
|
|
13
|
+
* @returns The processed body.
|
|
14
|
+
*/
|
|
15
|
+
handle(body: Uint8Array): Promise<unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IBaseRouteProcessor } from "./IBaseRouteProcessor";
|
|
2
|
+
import type { IHttpRequestIdentity } from "../protocol/IHttpRequestIdentity";
|
|
3
|
+
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
4
|
+
import type { IHttpServerRequest } from "../protocol/IHttpServerRequest";
|
|
5
|
+
import type { IRestRoute } from "../routes/IRestRoute";
|
|
6
|
+
/**
|
|
7
|
+
* The definition for a processor for handling REST routes.
|
|
8
|
+
*/
|
|
9
|
+
export interface IRestRouteProcessor extends IBaseRouteProcessor<IRestRoute> {
|
|
10
|
+
/**
|
|
11
|
+
* Process the REST request for the specified route.
|
|
12
|
+
* @param request The request to handle.
|
|
13
|
+
* @param response The response data to send if any.
|
|
14
|
+
* @param route The route being requested, if a matching one was found.
|
|
15
|
+
* @param requestIdentity The identity context for the request.
|
|
16
|
+
* @param processorState The state handed through the processors.
|
|
17
|
+
* @returns Promise that resolves when the request is processed.
|
|
18
|
+
*/
|
|
19
|
+
process?(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
20
|
+
[id: string]: unknown;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
}
|
package/dist/types/models/server/{IHttpRestRouteProcessor.d.ts → ISocketRouteProcessor.d.ts}
RENAMED
|
@@ -1,46 +1,43 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IBaseRouteProcessor } from "./IBaseRouteProcessor";
|
|
2
2
|
import type { IHttpRequestIdentity } from "../protocol/IHttpRequestIdentity";
|
|
3
3
|
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
4
4
|
import type { IHttpServerRequest } from "../protocol/IHttpServerRequest";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ISocketRoute } from "../routes/ISocketRoute";
|
|
6
6
|
/**
|
|
7
|
-
* The definition for a processor for handling
|
|
7
|
+
* The definition for a processor for handling socket routes.
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
9
|
+
export interface ISocketRouteProcessor extends IBaseRouteProcessor<ISocketRoute> {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Process the connected event.
|
|
12
12
|
* @param request The request to handle.
|
|
13
|
-
* @param response The response data to send if any.
|
|
14
13
|
* @param route The route being requested, if a matching one was found.
|
|
15
|
-
* @param requestIdentity The identity context for the request.
|
|
16
14
|
* @param processorState The state handed through the processors.
|
|
17
15
|
* @returns Promise that resolves when the request is processed.
|
|
18
16
|
*/
|
|
19
|
-
|
|
17
|
+
connected?(request: IHttpServerRequest, route: ISocketRoute | undefined, processorState: {
|
|
20
18
|
[id: string]: unknown;
|
|
21
19
|
}): Promise<void>;
|
|
22
20
|
/**
|
|
23
|
-
* Process the
|
|
21
|
+
* Process the disconnected event.
|
|
24
22
|
* @param request The request to handle.
|
|
25
|
-
* @param response The response data to send if any.
|
|
26
23
|
* @param route The route being requested, if a matching one was found.
|
|
27
|
-
* @param requestIdentity The identity context for the request.
|
|
28
24
|
* @param processorState The state handed through the processors.
|
|
29
25
|
* @returns Promise that resolves when the request is processed.
|
|
30
26
|
*/
|
|
31
|
-
|
|
27
|
+
disconnected?(request: IHttpServerRequest, route: ISocketRoute | undefined, processorState: {
|
|
32
28
|
[id: string]: unknown;
|
|
33
29
|
}): Promise<void>;
|
|
34
30
|
/**
|
|
35
|
-
*
|
|
31
|
+
* Process the REST request for the specified route.
|
|
36
32
|
* @param request The request to handle.
|
|
37
33
|
* @param response The response data to send if any.
|
|
38
34
|
* @param route The route being requested, if a matching one was found.
|
|
39
35
|
* @param requestIdentity The identity context for the request.
|
|
40
36
|
* @param processorState The state handed through the processors.
|
|
37
|
+
* @param responseEmitter The function to emit a response.
|
|
41
38
|
* @returns Promise that resolves when the request is processed.
|
|
42
39
|
*/
|
|
43
|
-
|
|
40
|
+
process?(request: IHttpServerRequest, response: IHttpResponse, route: ISocketRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
|
|
44
41
|
[id: string]: unknown;
|
|
45
|
-
}): Promise<void>;
|
|
42
|
+
}, responseEmitter: (response: IHttpResponse) => Promise<void>): Promise<void>;
|
|
46
43
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IRestRouteProcessor } from "./IRestRouteProcessor";
|
|
2
|
+
import type { ISocketRouteProcessor } from "./ISocketRouteProcessor";
|
|
2
3
|
import type { IWebServerOptions } from "./IWebServerOptions";
|
|
3
4
|
import type { IRestRoute } from "../routes/IRestRoute";
|
|
5
|
+
import type { ISocketRoute } from "../routes/ISocketRoute";
|
|
4
6
|
/**
|
|
5
7
|
* Interface describing a web server.
|
|
6
8
|
*/
|
|
@@ -12,12 +14,14 @@ export interface IWebServer<T> {
|
|
|
12
14
|
getInstance(): T;
|
|
13
15
|
/**
|
|
14
16
|
* Build the server.
|
|
15
|
-
* @param restRouteProcessors The
|
|
17
|
+
* @param restRouteProcessors The processors for incoming requests over REST.
|
|
16
18
|
* @param restRoutes The REST routes.
|
|
19
|
+
* @param socketRouteProcessors The processors for incoming requests over Sockets.
|
|
20
|
+
* @param socketRoutes The socket routes.
|
|
17
21
|
* @param options Options for building the server.
|
|
18
22
|
* @returns Nothing.
|
|
19
23
|
*/
|
|
20
|
-
build(restRouteProcessors
|
|
24
|
+
build(restRouteProcessors?: IRestRouteProcessor[], restRoutes?: IRestRoute[], socketRouteProcessors?: ISocketRouteProcessor[], socketRoutes?: ISocketRoute[], options?: IWebServerOptions): Promise<void>;
|
|
21
25
|
/**
|
|
22
26
|
* Start the server.
|
|
23
27
|
* @returns Nothing.
|
package/docs/changelog.md
CHANGED
package/docs/reference/index.md
CHANGED
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
- [IRestRouteResponseOptions](interfaces/IRestRouteResponseOptions.md)
|
|
42
42
|
- [ISocketRoute](interfaces/ISocketRoute.md)
|
|
43
43
|
- [ITag](interfaces/ITag.md)
|
|
44
|
-
- [
|
|
44
|
+
- [IBaseRouteProcessor](interfaces/IBaseRouteProcessor.md)
|
|
45
|
+
- [IMimeTypeProcessor](interfaces/IMimeTypeProcessor.md)
|
|
46
|
+
- [IRestRouteProcessor](interfaces/IRestRouteProcessor.md)
|
|
47
|
+
- [ISocketRouteProcessor](interfaces/ISocketRouteProcessor.md)
|
|
45
48
|
- [IWebServer](interfaces/IWebServer.md)
|
|
46
49
|
- [IWebServerOptions](interfaces/IWebServerOptions.md)
|
|
47
50
|
- [IHealthInfo](interfaces/IHealthInfo.md)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Interface: IBaseRouteProcessor\<T\>
|
|
2
|
+
|
|
3
|
+
The definition for a base processor for handling REST routes.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `IComponent`
|
|
8
|
+
|
|
9
|
+
## Extended by
|
|
10
|
+
|
|
11
|
+
- [`IRestRouteProcessor`](IRestRouteProcessor.md)
|
|
12
|
+
- [`ISocketRouteProcessor`](ISocketRouteProcessor.md)
|
|
13
|
+
|
|
14
|
+
## Type Parameters
|
|
15
|
+
|
|
16
|
+
• **T** = [`IBaseRoute`](IBaseRoute.md)
|
|
17
|
+
|
|
18
|
+
## Methods
|
|
19
|
+
|
|
20
|
+
### pre()?
|
|
21
|
+
|
|
22
|
+
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
23
|
+
|
|
24
|
+
Pre process the REST request for the specified route.
|
|
25
|
+
|
|
26
|
+
#### Parameters
|
|
27
|
+
|
|
28
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
29
|
+
|
|
30
|
+
The request to handle.
|
|
31
|
+
|
|
32
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
33
|
+
|
|
34
|
+
The response data to send if any.
|
|
35
|
+
|
|
36
|
+
• **route**: `undefined` \| `T`
|
|
37
|
+
|
|
38
|
+
The route being requested, if a matching one was found.
|
|
39
|
+
|
|
40
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
41
|
+
|
|
42
|
+
The identity context for the request.
|
|
43
|
+
|
|
44
|
+
• **processorState**
|
|
45
|
+
|
|
46
|
+
The state handed through the processors.
|
|
47
|
+
|
|
48
|
+
#### Returns
|
|
49
|
+
|
|
50
|
+
`Promise`\<`void`\>
|
|
51
|
+
|
|
52
|
+
Promise that resolves when the request is processed.
|
|
53
|
+
|
|
54
|
+
***
|
|
55
|
+
|
|
56
|
+
### post()?
|
|
57
|
+
|
|
58
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
59
|
+
|
|
60
|
+
Post process the REST request for the specified route.
|
|
61
|
+
|
|
62
|
+
#### Parameters
|
|
63
|
+
|
|
64
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
65
|
+
|
|
66
|
+
The request to handle.
|
|
67
|
+
|
|
68
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
69
|
+
|
|
70
|
+
The response data to send if any.
|
|
71
|
+
|
|
72
|
+
• **route**: `undefined` \| `T`
|
|
73
|
+
|
|
74
|
+
The route being requested, if a matching one was found.
|
|
75
|
+
|
|
76
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
77
|
+
|
|
78
|
+
The identity context for the request.
|
|
79
|
+
|
|
80
|
+
• **processorState**
|
|
81
|
+
|
|
82
|
+
The state handed through the processors.
|
|
83
|
+
|
|
84
|
+
#### Returns
|
|
85
|
+
|
|
86
|
+
`Promise`\<`void`\>
|
|
87
|
+
|
|
88
|
+
Promise that resolves when the request is processed.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Interface: IMimeTypeProcessor
|
|
2
|
+
|
|
3
|
+
The definition for a handler for a specific MIME type.
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
### getTypes()
|
|
8
|
+
|
|
9
|
+
> **getTypes**(): `string`[]
|
|
10
|
+
|
|
11
|
+
Get the MIME types that this handler can handle.
|
|
12
|
+
|
|
13
|
+
#### Returns
|
|
14
|
+
|
|
15
|
+
`string`[]
|
|
16
|
+
|
|
17
|
+
The MIME types that this handler can handle.
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### handle()
|
|
22
|
+
|
|
23
|
+
> **handle**(`body`): `Promise`\<`unknown`\>
|
|
24
|
+
|
|
25
|
+
Handle content.
|
|
26
|
+
|
|
27
|
+
#### Parameters
|
|
28
|
+
|
|
29
|
+
• **body**: `Uint8Array`
|
|
30
|
+
|
|
31
|
+
The body to process.
|
|
32
|
+
|
|
33
|
+
#### Returns
|
|
34
|
+
|
|
35
|
+
`Promise`\<`unknown`\>
|
|
36
|
+
|
|
37
|
+
The processed body.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Interface:
|
|
1
|
+
# Interface: IRestRouteProcessor
|
|
2
2
|
|
|
3
3
|
The definition for a processor for handling REST routes.
|
|
4
4
|
|
|
5
5
|
## Extends
|
|
6
6
|
|
|
7
|
-
- `
|
|
7
|
+
- [`IBaseRouteProcessor`](IBaseRouteProcessor.md)\<[`IRestRoute`](IRestRoute.md)\>
|
|
8
8
|
|
|
9
9
|
## Methods
|
|
10
10
|
|
|
@@ -42,13 +42,17 @@ The state handed through the processors.
|
|
|
42
42
|
|
|
43
43
|
Promise that resolves when the request is processed.
|
|
44
44
|
|
|
45
|
+
#### Inherited from
|
|
46
|
+
|
|
47
|
+
[`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`pre`](IBaseRouteProcessor.md#pre)
|
|
48
|
+
|
|
45
49
|
***
|
|
46
50
|
|
|
47
|
-
###
|
|
51
|
+
### post()?
|
|
48
52
|
|
|
49
|
-
> `optional` **
|
|
53
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
Post process the REST request for the specified route.
|
|
52
56
|
|
|
53
57
|
#### Parameters
|
|
54
58
|
|
|
@@ -78,13 +82,17 @@ The state handed through the processors.
|
|
|
78
82
|
|
|
79
83
|
Promise that resolves when the request is processed.
|
|
80
84
|
|
|
85
|
+
#### Inherited from
|
|
86
|
+
|
|
87
|
+
[`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`post`](IBaseRouteProcessor.md#post)
|
|
88
|
+
|
|
81
89
|
***
|
|
82
90
|
|
|
83
|
-
###
|
|
91
|
+
### process()?
|
|
84
92
|
|
|
85
|
-
> `optional` **
|
|
93
|
+
> `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
86
94
|
|
|
87
|
-
|
|
95
|
+
Process the REST request for the specified route.
|
|
88
96
|
|
|
89
97
|
#### Parameters
|
|
90
98
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Interface: ISocketRoute
|
|
1
|
+
# Interface: ISocketRoute\<T, U\>
|
|
2
2
|
|
|
3
3
|
Interface which defines a socket route.
|
|
4
4
|
|
|
@@ -6,6 +6,12 @@ Interface which defines a socket route.
|
|
|
6
6
|
|
|
7
7
|
- [`IBaseRoute`](IBaseRoute.md)
|
|
8
8
|
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
• **T** *extends* [`IHttpRequest`](IHttpRequest.md) = `any`
|
|
12
|
+
|
|
13
|
+
• **U** *extends* [`IHttpResponse`](IHttpResponse.md) = `any`
|
|
14
|
+
|
|
9
15
|
## Properties
|
|
10
16
|
|
|
11
17
|
### operationId
|
|
@@ -46,7 +52,7 @@ Skips the authentication for this route.
|
|
|
46
52
|
|
|
47
53
|
### handler()
|
|
48
54
|
|
|
49
|
-
> **handler**: (`httpRequestContext`, `
|
|
55
|
+
> **handler**: (`httpRequestContext`, `request`, `emit`) => `void`
|
|
50
56
|
|
|
51
57
|
The handler module.
|
|
52
58
|
|
|
@@ -56,18 +62,14 @@ The handler module.
|
|
|
56
62
|
|
|
57
63
|
The request context.
|
|
58
64
|
|
|
59
|
-
• **
|
|
60
|
-
|
|
61
|
-
The id of the socket the request is arriving on.
|
|
62
|
-
|
|
63
|
-
• **request**: `unknown`
|
|
65
|
+
• **request**: `T`
|
|
64
66
|
|
|
65
67
|
The request object.
|
|
66
68
|
|
|
67
|
-
• **
|
|
69
|
+
• **emit**
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
The function to emit a message.
|
|
70
72
|
|
|
71
73
|
#### Returns
|
|
72
74
|
|
|
73
|
-
`
|
|
75
|
+
`void`
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Interface: ISocketRouteProcessor
|
|
2
|
+
|
|
3
|
+
The definition for a processor for handling socket routes.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- [`IBaseRouteProcessor`](IBaseRouteProcessor.md)\<[`ISocketRoute`](ISocketRoute.md)\>
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### pre()?
|
|
12
|
+
|
|
13
|
+
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
14
|
+
|
|
15
|
+
Pre process the REST request for the specified route.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
20
|
+
|
|
21
|
+
The request to handle.
|
|
22
|
+
|
|
23
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
24
|
+
|
|
25
|
+
The response data to send if any.
|
|
26
|
+
|
|
27
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
28
|
+
|
|
29
|
+
The route being requested, if a matching one was found.
|
|
30
|
+
|
|
31
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
32
|
+
|
|
33
|
+
The identity context for the request.
|
|
34
|
+
|
|
35
|
+
• **processorState**
|
|
36
|
+
|
|
37
|
+
The state handed through the processors.
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
`Promise`\<`void`\>
|
|
42
|
+
|
|
43
|
+
Promise that resolves when the request is processed.
|
|
44
|
+
|
|
45
|
+
#### Inherited from
|
|
46
|
+
|
|
47
|
+
[`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`pre`](IBaseRouteProcessor.md#pre)
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### post()?
|
|
52
|
+
|
|
53
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
54
|
+
|
|
55
|
+
Post process the REST request for the specified route.
|
|
56
|
+
|
|
57
|
+
#### Parameters
|
|
58
|
+
|
|
59
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
60
|
+
|
|
61
|
+
The request to handle.
|
|
62
|
+
|
|
63
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
64
|
+
|
|
65
|
+
The response data to send if any.
|
|
66
|
+
|
|
67
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
68
|
+
|
|
69
|
+
The route being requested, if a matching one was found.
|
|
70
|
+
|
|
71
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
72
|
+
|
|
73
|
+
The identity context for the request.
|
|
74
|
+
|
|
75
|
+
• **processorState**
|
|
76
|
+
|
|
77
|
+
The state handed through the processors.
|
|
78
|
+
|
|
79
|
+
#### Returns
|
|
80
|
+
|
|
81
|
+
`Promise`\<`void`\>
|
|
82
|
+
|
|
83
|
+
Promise that resolves when the request is processed.
|
|
84
|
+
|
|
85
|
+
#### Inherited from
|
|
86
|
+
|
|
87
|
+
[`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`post`](IBaseRouteProcessor.md#post)
|
|
88
|
+
|
|
89
|
+
***
|
|
90
|
+
|
|
91
|
+
### connected()?
|
|
92
|
+
|
|
93
|
+
> `optional` **connected**(`request`, `route`, `processorState`): `Promise`\<`void`\>
|
|
94
|
+
|
|
95
|
+
Process the connected event.
|
|
96
|
+
|
|
97
|
+
#### Parameters
|
|
98
|
+
|
|
99
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
100
|
+
|
|
101
|
+
The request to handle.
|
|
102
|
+
|
|
103
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
104
|
+
|
|
105
|
+
The route being requested, if a matching one was found.
|
|
106
|
+
|
|
107
|
+
• **processorState**
|
|
108
|
+
|
|
109
|
+
The state handed through the processors.
|
|
110
|
+
|
|
111
|
+
#### Returns
|
|
112
|
+
|
|
113
|
+
`Promise`\<`void`\>
|
|
114
|
+
|
|
115
|
+
Promise that resolves when the request is processed.
|
|
116
|
+
|
|
117
|
+
***
|
|
118
|
+
|
|
119
|
+
### disconnected()?
|
|
120
|
+
|
|
121
|
+
> `optional` **disconnected**(`request`, `route`, `processorState`): `Promise`\<`void`\>
|
|
122
|
+
|
|
123
|
+
Process the disconnected event.
|
|
124
|
+
|
|
125
|
+
#### Parameters
|
|
126
|
+
|
|
127
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
128
|
+
|
|
129
|
+
The request to handle.
|
|
130
|
+
|
|
131
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
132
|
+
|
|
133
|
+
The route being requested, if a matching one was found.
|
|
134
|
+
|
|
135
|
+
• **processorState**
|
|
136
|
+
|
|
137
|
+
The state handed through the processors.
|
|
138
|
+
|
|
139
|
+
#### Returns
|
|
140
|
+
|
|
141
|
+
`Promise`\<`void`\>
|
|
142
|
+
|
|
143
|
+
Promise that resolves when the request is processed.
|
|
144
|
+
|
|
145
|
+
***
|
|
146
|
+
|
|
147
|
+
### process()?
|
|
148
|
+
|
|
149
|
+
> `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `responseEmitter`): `Promise`\<`void`\>
|
|
150
|
+
|
|
151
|
+
Process the REST request for the specified route.
|
|
152
|
+
|
|
153
|
+
#### Parameters
|
|
154
|
+
|
|
155
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
156
|
+
|
|
157
|
+
The request to handle.
|
|
158
|
+
|
|
159
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
160
|
+
|
|
161
|
+
The response data to send if any.
|
|
162
|
+
|
|
163
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
164
|
+
|
|
165
|
+
The route being requested, if a matching one was found.
|
|
166
|
+
|
|
167
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
168
|
+
|
|
169
|
+
The identity context for the request.
|
|
170
|
+
|
|
171
|
+
• **processorState**
|
|
172
|
+
|
|
173
|
+
The state handed through the processors.
|
|
174
|
+
|
|
175
|
+
• **responseEmitter**
|
|
176
|
+
|
|
177
|
+
The function to emit a response.
|
|
178
|
+
|
|
179
|
+
#### Returns
|
|
180
|
+
|
|
181
|
+
`Promise`\<`void`\>
|
|
182
|
+
|
|
183
|
+
Promise that resolves when the request is processed.
|
|
@@ -24,20 +24,28 @@ The web server instance.
|
|
|
24
24
|
|
|
25
25
|
### build()
|
|
26
26
|
|
|
27
|
-
> **build**(`restRouteProcessors
|
|
27
|
+
> **build**(`restRouteProcessors`?, `restRoutes`?, `socketRouteProcessors`?, `socketRoutes`?, `options`?): `Promise`\<`void`\>
|
|
28
28
|
|
|
29
29
|
Build the server.
|
|
30
30
|
|
|
31
31
|
#### Parameters
|
|
32
32
|
|
|
33
|
-
• **restRouteProcessors
|
|
33
|
+
• **restRouteProcessors?**: [`IRestRouteProcessor`](IRestRouteProcessor.md)[]
|
|
34
34
|
|
|
35
|
-
The
|
|
35
|
+
The processors for incoming requests over REST.
|
|
36
36
|
|
|
37
|
-
• **restRoutes
|
|
37
|
+
• **restRoutes?**: [`IRestRoute`](IRestRoute.md)\<`any`, `any`\>[]
|
|
38
38
|
|
|
39
39
|
The REST routes.
|
|
40
40
|
|
|
41
|
+
• **socketRouteProcessors?**: [`ISocketRouteProcessor`](ISocketRouteProcessor.md)[]
|
|
42
|
+
|
|
43
|
+
The processors for incoming requests over Sockets.
|
|
44
|
+
|
|
45
|
+
• **socketRoutes?**: [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>[]
|
|
46
|
+
|
|
47
|
+
The socket routes.
|
|
48
|
+
|
|
41
49
|
• **options?**: [`IWebServerOptions`](IWebServerOptions.md)
|
|
42
50
|
|
|
43
51
|
Options for building the server.
|