@clairejs/server 3.19.1 → 3.19.2

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 CHANGED
@@ -1,7 +1,8 @@
1
1
  ## Change Log
2
2
 
3
- #### 3.19.1:
3
+ #### 3.19.2:
4
4
 
5
+ - fix isEndpoint
5
6
  - fix ModelRepository getMany
6
7
  - adapt interface with new claire orm
7
8
 
@@ -1 +1,9 @@
1
- export {};
1
+ import { HttpMethod } from "@clairejs/core";
2
+ export interface HttpData {
3
+ clientIP?: string;
4
+ method: HttpMethod;
5
+ fullPath: string;
6
+ body: any;
7
+ headers?: object;
8
+ cookies?: object;
9
+ }
@@ -4,5 +4,6 @@ import { Transactionable } from "../../common/Transactionable";
4
4
  export declare abstract class AbstractHttpController extends Transactionable {
5
5
  protected readonly db: ITransactionFactory;
6
6
  constructor(db: ITransactionFactory);
7
+ protected isEndpoint(metadata: EndpointMetadata): boolean;
7
8
  getEndpointMetadata(): Readonly<EndpointMetadata>[];
8
9
  }
@@ -1,19 +1,19 @@
1
1
  import { getObjectMetadata } from "@clairejs/core";
2
2
  import { Transactionable } from "../../common/Transactionable";
3
- const isEndpoint = (metadata) => {
4
- return !!metadata.method;
5
- };
6
3
  export class AbstractHttpController extends Transactionable {
7
4
  db;
8
5
  constructor(db) {
9
6
  super(db);
10
7
  this.db = db;
11
8
  }
9
+ isEndpoint(metadata) {
10
+ return !!metadata.method;
11
+ }
12
12
  getEndpointMetadata() {
13
13
  const controllerMetadata = getObjectMetadata(this.constructor);
14
14
  if (!controllerMetadata) {
15
15
  return [];
16
16
  }
17
- return controllerMetadata.fields.filter((f) => isEndpoint(f));
17
+ return controllerMetadata.fields.filter((f) => this.isEndpoint(f));
18
18
  }
19
19
  }
@@ -14,6 +14,7 @@ export declare class CrudHttpController<T extends Identifiable> extends Abstract
14
14
  constructor(model: Constructor<T>, crudRepository: ICrudRepository<T>, db: ITransactionFactory & IQueryProvider);
15
15
  protected getMountedUrl(): string;
16
16
  private getAuthProvider;
17
+ protected isEndpoint(metadata: EndpointMetadata): boolean;
17
18
  /**
18
19
  * This provides endpoint metadata for mounting /POST request.
19
20
  */
@@ -40,6 +40,16 @@ export class CrudHttpController extends AbstractHttpController {
40
40
  }
41
41
  return this.principalResolver;
42
42
  }
43
+ isEndpoint(metadata) {
44
+ return (super.isEndpoint(metadata) ||
45
+ [
46
+ CrudHttpController.prototype.createMany.name,
47
+ CrudHttpController.prototype.getMany.name,
48
+ CrudHttpController.prototype.updateMany.name,
49
+ CrudHttpController.prototype.deleteMany.name,
50
+ CrudHttpController.prototype.updateRecords.name,
51
+ ].includes(metadata.name));
52
+ }
43
53
  /**
44
54
  * This provides endpoint metadata for mounting /POST request.
45
55
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.19.1",
3
+ "version": "3.19.2",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@clairejs/core": "^3.7.9",
37
- "@clairejs/orm": "^3.15.0"
37
+ "@clairejs/orm": "^3.15.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/cookie-parser": "^1.4.3",