@clairejs/server 3.17.6 → 3.17.8
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/README.md +3 -2
- package/dist/common/request/endpoint-metadata.d.ts +0 -1
- package/dist/http/controller/AbstractHttpController.js +1 -3
- package/dist/http/controller/AbstractHttpRequestHandler.js +3 -1
- package/dist/http/controller/CrudHttpController.js +10 -10
- package/dist/http/controller/DefaultHttpRequestHandler.js +1 -1
- package/dist/http/decorators.js +0 -1
- package/dist/socket/AbstractServerSocketManager.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
-
#### 3.17.
|
|
3
|
+
#### 3.17.8:
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- remove handlerFunctionName (using name & displayName instead)
|
|
6
|
+
- fix missing controller & handlerFunctionName in EndpointMetadata
|
|
6
7
|
- remove AbstractController
|
|
7
8
|
- mount socket metadata from getChannelName
|
|
8
9
|
- refactor EndpointMetadata, remove MountedEndpointInfo
|
|
@@ -2,7 +2,6 @@ import { type ApiInfo, type Constructor, type ObjectFieldMetadata } from "@clair
|
|
|
2
2
|
import { type RequestDataSource } from "./types";
|
|
3
3
|
export interface EndpointMetadata extends ApiInfo, ObjectFieldMetadata {
|
|
4
4
|
controller: any;
|
|
5
|
-
handlerFunctionName: string;
|
|
6
5
|
params?: {
|
|
7
6
|
[index: number]: {
|
|
8
7
|
source?: RequestDataSource;
|
|
@@ -14,8 +14,6 @@ export class AbstractHttpController extends Transactionable {
|
|
|
14
14
|
if (!controllerMetadata) {
|
|
15
15
|
return [];
|
|
16
16
|
}
|
|
17
|
-
return controllerMetadata.fields
|
|
18
|
-
.filter((f) => isEndpoint(f))
|
|
19
|
-
.map((f) => ({ ...f, apiGroup: controllerMetadata.permissionGroup, controller: this }));
|
|
17
|
+
return controllerMetadata.fields.filter((f) => isEndpoint(f));
|
|
20
18
|
}
|
|
21
19
|
}
|
|
@@ -35,6 +35,8 @@ export class AbstractHttpRequestHandler {
|
|
|
35
35
|
: this.resolveMountPoint(controllerMetadata, [this.mountPoint || "/", endpoint.mount]);
|
|
36
36
|
return {
|
|
37
37
|
...endpoint,
|
|
38
|
+
apiGroup: controllerMetadata.permissionGroup,
|
|
39
|
+
controller,
|
|
38
40
|
id: `${endpoint.method}:${mount}`,
|
|
39
41
|
mount,
|
|
40
42
|
readOnly: endpoint.method === HttpMethod.GET,
|
|
@@ -48,7 +50,7 @@ export class AbstractHttpRequestHandler {
|
|
|
48
50
|
const overridingEndpoint = mountedEndpointInfo.find((info) => info.mount === endpointInfo.mount && info.method === endpointInfo.method);
|
|
49
51
|
if (overridingEndpoint) {
|
|
50
52
|
//-- if this endpoint has an other overriden endpoints then do not mount
|
|
51
|
-
this.logger?.warn(`Implicit overriding endpoint: ${overridingEndpoint.method}:${overridingEndpoint.mount} of ${overridingEndpoint.controller?.constructor.name}:${overridingEndpoint.
|
|
53
|
+
this.logger?.warn(`Implicit overriding endpoint: ${overridingEndpoint.method}:${overridingEndpoint.mount} of ${overridingEndpoint.controller?.constructor.name}:${overridingEndpoint.name}`, `Ignore ${endpointInfo.method}:${endpointInfo.mount} of ${endpointInfo.controller?.constructor.name}:${endpointInfo.name}`);
|
|
52
54
|
}
|
|
53
55
|
else {
|
|
54
56
|
mountedEndpointInfo.push(endpointInfo);
|
|
@@ -47,8 +47,8 @@ export class CrudHttpController extends AbstractHttpController {
|
|
|
47
47
|
const endpointMetadata = {};
|
|
48
48
|
endpointMetadata.method = HttpMethod.POST;
|
|
49
49
|
endpointMetadata.mount = this.getMountedUrl();
|
|
50
|
-
endpointMetadata.
|
|
51
|
-
endpointMetadata.
|
|
50
|
+
endpointMetadata.displayName = "createMany" + this.model.name;
|
|
51
|
+
endpointMetadata.name = CrudHttpController.prototype.createMany.name;
|
|
52
52
|
//-- body dto ------------------------------------
|
|
53
53
|
endpointMetadata.bodyDto = getCreateManyBodyValidator(this.modelMetadata);
|
|
54
54
|
//-- response dto ------------------------------------
|
|
@@ -64,8 +64,8 @@ export class CrudHttpController extends AbstractHttpController {
|
|
|
64
64
|
const endpointMetadata = {};
|
|
65
65
|
endpointMetadata.method = HttpMethod.GET;
|
|
66
66
|
endpointMetadata.mount = this.getMountedUrl();
|
|
67
|
-
endpointMetadata.
|
|
68
|
-
endpointMetadata.
|
|
67
|
+
endpointMetadata.name = CrudHttpController.prototype.getMany.name;
|
|
68
|
+
endpointMetadata.displayName = "getAll" + this.model.name;
|
|
69
69
|
//-- query dto
|
|
70
70
|
endpointMetadata.queryDto = getGetManyQueryValidator(this.modelMetadata);
|
|
71
71
|
//-- response dto ------------------------------------
|
|
@@ -80,8 +80,8 @@ export class CrudHttpController extends AbstractHttpController {
|
|
|
80
80
|
const endpointMetadata = {};
|
|
81
81
|
endpointMetadata.method = HttpMethod.PUT;
|
|
82
82
|
endpointMetadata.mount = this.getMountedUrl();
|
|
83
|
-
endpointMetadata.
|
|
84
|
-
endpointMetadata.
|
|
83
|
+
endpointMetadata.name = CrudHttpController.prototype.updateMany.name;
|
|
84
|
+
endpointMetadata.displayName = "update" + this.model.name;
|
|
85
85
|
//-- queries dto ---------------------------------
|
|
86
86
|
endpointMetadata.queryDto = getUpdateManyQueryValidator(this.modelMetadata);
|
|
87
87
|
//-- body dto ------------------------------------
|
|
@@ -95,8 +95,8 @@ export class CrudHttpController extends AbstractHttpController {
|
|
|
95
95
|
const endpointMetadata = {};
|
|
96
96
|
endpointMetadata.method = HttpMethod.PUT;
|
|
97
97
|
endpointMetadata.mount = `${this.getMountedUrl()}/records`;
|
|
98
|
-
endpointMetadata.
|
|
99
|
-
endpointMetadata.
|
|
98
|
+
endpointMetadata.name = CrudHttpController.prototype.updateRecords.name;
|
|
99
|
+
endpointMetadata.displayName = "updateRecords" + this.model.name;
|
|
100
100
|
//-- queries dto ---------------------------------
|
|
101
101
|
endpointMetadata.queryDto = getUpdateRecordsQueryValidator();
|
|
102
102
|
//-- body dto ------------------------------------
|
|
@@ -112,8 +112,8 @@ export class CrudHttpController extends AbstractHttpController {
|
|
|
112
112
|
const endpointMetadata = {};
|
|
113
113
|
endpointMetadata.method = HttpMethod.DEL;
|
|
114
114
|
endpointMetadata.mount = this.getMountedUrl();
|
|
115
|
-
endpointMetadata.
|
|
116
|
-
endpointMetadata.
|
|
115
|
+
endpointMetadata.name = CrudHttpController.prototype.deleteMany.name;
|
|
116
|
+
endpointMetadata.displayName = "delete" + this.model.name;
|
|
117
117
|
//-- queries ---------------------------------
|
|
118
118
|
endpointMetadata.queryDto = getUpdateManyQueryValidator(this.modelMetadata);
|
|
119
119
|
endpointMetadata.responseDto = getUpdateManyResponseValidator(this.modelMetadata);
|
|
@@ -45,7 +45,7 @@ let DefaultHttpRequestHandler = class DefaultHttpRequestHandler extends Abstract
|
|
|
45
45
|
return req;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
const response = await endpoint.controller[endpoint.
|
|
48
|
+
const response = await endpoint.controller[endpoint.name](...params);
|
|
49
49
|
//-- validate response value against response dto
|
|
50
50
|
if (endpoint.responseDto) {
|
|
51
51
|
response.value = stripData(response.value, endpoint.responseDto);
|
package/dist/http/decorators.js
CHANGED
|
@@ -8,7 +8,6 @@ export const Endpoint = (config) => (prototype, propertyKey) => {
|
|
|
8
8
|
endpointMetadata.method = config.method;
|
|
9
9
|
//-- default to "/" if empty string is provided
|
|
10
10
|
endpointMetadata.mount = config.url || "/";
|
|
11
|
-
endpointMetadata.handlerFunctionName = propertyKey;
|
|
12
11
|
};
|
|
13
12
|
const HttpMethodDecoratorFactory = (method) => (url) => (prototype, propertyKey, _descriptor) => Endpoint({ method, url })(prototype, propertyKey);
|
|
14
13
|
export const Post = HttpMethodDecoratorFactory(HttpMethod.POST);
|
|
@@ -289,11 +289,11 @@ export class AbstractServerSocketManager {
|
|
|
289
289
|
id: `${SocketMethod.MESSAGE}:${controller.getChannelName()}`,
|
|
290
290
|
readOnly: false,
|
|
291
291
|
controller: socketController,
|
|
292
|
-
|
|
292
|
+
name: controller.onMessage.name,
|
|
293
293
|
method: SocketMethod.MESSAGE,
|
|
294
294
|
mount: controller.getChannelName(),
|
|
295
295
|
description: "Send / Receive message to / from channel",
|
|
296
|
-
|
|
296
|
+
displayName: controller.getChannelName(),
|
|
297
297
|
dataType: DataType.OBJECT,
|
|
298
298
|
};
|
|
299
299
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clairejs/server",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.8",
|
|
4
4
|
"description": "Claire server NodeJs framework written in Typescript.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"ws": "^7.5.5"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@clairejs/core": "^3.7.
|
|
36
|
+
"@clairejs/core": "^3.7.3",
|
|
37
37
|
"@clairejs/orm": "^3.12.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|