@twin.org/api-models 0.0.1-next.12 → 0.0.1-next.14

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.
@@ -25,6 +25,7 @@ export * from "./models/responses/success/ICreatedResponse";
25
25
  export * from "./models/responses/success/INoContentResponse";
26
26
  export * from "./models/responses/success/IOkResponse";
27
27
  export * from "./models/routes/IBaseRoute";
28
+ export * from "./models/routes/IBaseRouteEntryPoint";
28
29
  export * from "./models/routes/IRestRoute";
29
30
  export * from "./models/routes/IRestRouteEntryPoint";
30
31
  export * from "./models/routes/IRestRouteExample";
@@ -33,9 +34,12 @@ export * from "./models/routes/IRestRouteResponseAttachmentOptions";
33
34
  export * from "./models/routes/IRestRouteResponseExample";
34
35
  export * from "./models/routes/IRestRouteResponseOptions";
35
36
  export * from "./models/routes/ISocketRoute";
37
+ export * from "./models/routes/ISocketRouteEntryPoint";
36
38
  export * from "./models/routes/ITag";
37
- export * from "./models/server/IHttpRestRouteProcessor";
39
+ export * from "./models/server/IBaseRouteProcessor";
38
40
  export * from "./models/server/IMimeTypeProcessor";
41
+ export * from "./models/server/IRestRouteProcessor";
42
+ export * from "./models/server/ISocketRouteProcessor";
39
43
  export * from "./models/server/IWebServer";
40
44
  export * from "./models/server/IWebServerOptions";
41
45
  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
  */
@@ -0,0 +1,22 @@
1
+ import type { ITag } from "./ITag";
2
+ /**
3
+ * Route entry points are used for exposing the routes from a package.
4
+ */
5
+ export interface IBaseRouteEntryPoint<T> {
6
+ /**
7
+ * The name of the routes.
8
+ */
9
+ name: string;
10
+ /**
11
+ * The default base route name for the routes.
12
+ */
13
+ defaultBaseRoute: string;
14
+ /**
15
+ * The tags for the routes.
16
+ */
17
+ tags: ITag[];
18
+ /**
19
+ * The method to generate the routes.
20
+ */
21
+ generateRoutes: (baseRouteName: string, componentName: string) => T[];
22
+ }
@@ -1,23 +1,6 @@
1
+ import type { IBaseRouteEntryPoint } from "./IBaseRouteEntryPoint";
1
2
  import type { IRestRoute } from "./IRestRoute";
2
- import type { ITag } from "./ITag";
3
3
  /**
4
4
  * Route entry points are used for exposing the REST routes from a package.
5
5
  */
6
- export interface IRestRouteEntryPoint {
7
- /**
8
- * The name of the REST routes.
9
- */
10
- name: string;
11
- /**
12
- * The default base route name for the REST routes.
13
- */
14
- defaultBaseRoute: string;
15
- /**
16
- * The tags for the REST routes.
17
- */
18
- tags: ITag[];
19
- /**
20
- * The method to generate the REST routes.
21
- */
22
- generateRoutes: (baseRouteName: string, componentName: string) => IRestRoute[];
23
- }
6
+ export type IRestRouteEntryPoint = IBaseRouteEntryPoint<IRestRoute>;
@@ -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: unknown,
20
+ request: T,
23
21
  /**
24
- * Method to emit data on the socket.
22
+ * The function to emit a message.
25
23
  */
26
- emitter: (topic: string, response?: unknown) => Promise<void>) => Promise<void>;
24
+ emit: (response: U) => Promise<void>) => void;
27
25
  }
@@ -0,0 +1,6 @@
1
+ import type { IBaseRouteEntryPoint } from "./IBaseRouteEntryPoint";
2
+ import type { ISocketRoute } from "./ISocketRoute";
3
+ /**
4
+ * Route entry points are used for exposing the socket routes from a package.
5
+ */
6
+ export type ISocketRouteEntryPoint = IBaseRouteEntryPoint<ISocketRoute>;
@@ -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,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
+ }
@@ -1,46 +1,43 @@
1
- import type { IComponent } from "@twin.org/core";
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 { IRestRoute } from "../routes/IRestRoute";
5
+ import type { ISocketRoute } from "../routes/ISocketRoute";
6
6
  /**
7
- * The definition for a processor for handling REST routes.
7
+ * The definition for a processor for handling socket routes.
8
8
  */
9
- export interface IHttpRestRouteProcessor extends IComponent {
9
+ export interface ISocketRouteProcessor extends IBaseRouteProcessor<ISocketRoute> {
10
10
  /**
11
- * Pre process the REST request for the specified route.
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
- pre?(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
17
+ connected?(request: IHttpServerRequest, route: ISocketRoute | undefined, processorState: {
20
18
  [id: string]: unknown;
21
19
  }): Promise<void>;
22
20
  /**
23
- * Process the REST request for the specified route.
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
- process?(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
27
+ disconnected?(request: IHttpServerRequest, route: ISocketRoute | undefined, processorState: {
32
28
  [id: string]: unknown;
33
29
  }): Promise<void>;
34
30
  /**
35
- * Post process the REST request for the specified route.
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
- post?(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
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 { IHttpRestRouteProcessor } from "./IHttpRestRouteProcessor";
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 hooks to process the incoming requests.
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: IHttpRestRouteProcessor[], restRoutes: IRestRoute[], options?: IWebServerOptions): Promise<void>;
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
@@ -1,5 +1,5 @@
1
1
  # @twin.org/api-models - Changelog
2
2
 
3
- ## v0.0.1-next.12
3
+ ## v0.0.1-next.14
4
4
 
5
5
  - Initial Release
@@ -32,8 +32,8 @@
32
32
  - [INoContentResponse](interfaces/INoContentResponse.md)
33
33
  - [IOkResponse](interfaces/IOkResponse.md)
34
34
  - [IBaseRoute](interfaces/IBaseRoute.md)
35
+ - [IBaseRouteEntryPoint](interfaces/IBaseRouteEntryPoint.md)
35
36
  - [IRestRoute](interfaces/IRestRoute.md)
36
- - [IRestRouteEntryPoint](interfaces/IRestRouteEntryPoint.md)
37
37
  - [IRestRouteExample](interfaces/IRestRouteExample.md)
38
38
  - [IRestRouteRequestExample](interfaces/IRestRouteRequestExample.md)
39
39
  - [IRestRouteResponseAttachmentOptions](interfaces/IRestRouteResponseAttachmentOptions.md)
@@ -41,8 +41,10 @@
41
41
  - [IRestRouteResponseOptions](interfaces/IRestRouteResponseOptions.md)
42
42
  - [ISocketRoute](interfaces/ISocketRoute.md)
43
43
  - [ITag](interfaces/ITag.md)
44
- - [IHttpRestRouteProcessor](interfaces/IHttpRestRouteProcessor.md)
44
+ - [IBaseRouteProcessor](interfaces/IBaseRouteProcessor.md)
45
45
  - [IMimeTypeProcessor](interfaces/IMimeTypeProcessor.md)
46
+ - [IRestRouteProcessor](interfaces/IRestRouteProcessor.md)
47
+ - [ISocketRouteProcessor](interfaces/ISocketRouteProcessor.md)
46
48
  - [IWebServer](interfaces/IWebServer.md)
47
49
  - [IWebServerOptions](interfaces/IWebServerOptions.md)
48
50
  - [IHealthInfo](interfaces/IHealthInfo.md)
@@ -51,6 +53,8 @@
51
53
 
52
54
  ## Type Aliases
53
55
 
56
+ - [IRestRouteEntryPoint](type-aliases/IRestRouteEntryPoint.md)
57
+ - [ISocketRouteEntryPoint](type-aliases/ISocketRouteEntryPoint.md)
54
58
  - [HealthStatus](type-aliases/HealthStatus.md)
55
59
 
56
60
  ## Variables
@@ -0,0 +1,49 @@
1
+ # Interface: IBaseRouteEntryPoint\<T\>
2
+
3
+ Route entry points are used for exposing the routes from a package.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T**
8
+
9
+ ## Properties
10
+
11
+ ### name
12
+
13
+ > **name**: `string`
14
+
15
+ The name of the routes.
16
+
17
+ ***
18
+
19
+ ### defaultBaseRoute
20
+
21
+ > **defaultBaseRoute**: `string`
22
+
23
+ The default base route name for the routes.
24
+
25
+ ***
26
+
27
+ ### tags
28
+
29
+ > **tags**: [`ITag`](ITag.md)[]
30
+
31
+ The tags for the routes.
32
+
33
+ ***
34
+
35
+ ### generateRoutes()
36
+
37
+ > **generateRoutes**: (`baseRouteName`, `componentName`) => `T`[]
38
+
39
+ The method to generate the routes.
40
+
41
+ #### Parameters
42
+
43
+ • **baseRouteName**: `string`
44
+
45
+ • **componentName**: `string`
46
+
47
+ #### Returns
48
+
49
+ `T`[]
@@ -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.
@@ -4,6 +4,14 @@ Definition for the configuration of a socket service.
4
4
 
5
5
  ## Properties
6
6
 
7
+ ### basePath?
8
+
9
+ > `optional` **basePath**: `string`
10
+
11
+ Base path for the socket service, defaults to /socket.
12
+
13
+ ***
14
+
7
15
  ### endpoint
8
16
 
9
17
  > **endpoint**: `string`
@@ -1,10 +1,10 @@
1
- # Interface: IHttpRestRouteProcessor
1
+ # Interface: IRestRouteProcessor
2
2
 
3
3
  The definition for a processor for handling REST routes.
4
4
 
5
5
  ## Extends
6
6
 
7
- - `IComponent`
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
- ### process()?
51
+ ### post()?
48
52
 
49
- > `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
53
+ > `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
50
54
 
51
- Process the REST request for the specified route.
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
- ### post()?
91
+ ### process()?
84
92
 
85
- > `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
93
+ > `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
86
94
 
87
- Post process the REST request for the specified route.
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`, `socketId`, `request`, `emitter`) => `Promise`\<`void`\>
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
- • **socketId**: `string`
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
- • **emitter**
69
+ • **emit**
68
70
 
69
- Method to emit data on the socket.
71
+ The function to emit a message.
70
72
 
71
73
  #### Returns
72
74
 
73
- `Promise`\<`void`\>
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`, `restRoutes`, `options`?): `Promise`\<`void`\>
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**: [`IHttpRestRouteProcessor`](IHttpRestRouteProcessor.md)[]
33
+ • **restRouteProcessors?**: [`IRestRouteProcessor`](IRestRouteProcessor.md)[]
34
34
 
35
- The hooks to process the incoming requests.
35
+ The processors for incoming requests over REST.
36
36
 
37
- • **restRoutes**: [`IRestRoute`](IRestRoute.md)\<`any`, `any`\>[]
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.
@@ -0,0 +1,5 @@
1
+ # Type Alias: IRestRouteEntryPoint
2
+
3
+ > **IRestRouteEntryPoint**: [`IBaseRouteEntryPoint`](../interfaces/IBaseRouteEntryPoint.md)\<[`IRestRoute`](../interfaces/IRestRoute.md)\>
4
+
5
+ Route entry points are used for exposing the REST routes from a package.
@@ -0,0 +1,5 @@
1
+ # Type Alias: ISocketRouteEntryPoint
2
+
3
+ > **ISocketRouteEntryPoint**: [`IBaseRouteEntryPoint`](../interfaces/IBaseRouteEntryPoint.md)\<[`ISocketRoute`](../interfaces/ISocketRoute.md)\>
4
+
5
+ Route entry points are used for exposing the socket routes from a package.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-models",
3
- "version": "0.0.1-next.12",
3
+ "version": "0.0.1-next.14",
4
4
  "description": "Contains models and classes for use with APIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,45 +0,0 @@
1
- # Interface: IRestRouteEntryPoint
2
-
3
- Route entry points are used for exposing the REST routes from a package.
4
-
5
- ## Properties
6
-
7
- ### name
8
-
9
- > **name**: `string`
10
-
11
- The name of the REST routes.
12
-
13
- ***
14
-
15
- ### defaultBaseRoute
16
-
17
- > **defaultBaseRoute**: `string`
18
-
19
- The default base route name for the REST routes.
20
-
21
- ***
22
-
23
- ### tags
24
-
25
- > **tags**: [`ITag`](ITag.md)[]
26
-
27
- The tags for the REST routes.
28
-
29
- ***
30
-
31
- ### generateRoutes()
32
-
33
- > **generateRoutes**: (`baseRouteName`, `componentName`) => [`IRestRoute`](IRestRoute.md)\<`any`, `any`\>[]
34
-
35
- The method to generate the REST routes.
36
-
37
- #### Parameters
38
-
39
- • **baseRouteName**: `string`
40
-
41
- • **componentName**: `string`
42
-
43
- #### Returns
44
-
45
- [`IRestRoute`](IRestRoute.md)\<`any`, `any`\>[]