@cryptexlabs/codex-nodejs-common 0.10.11 → 0.10.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/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptexlabs/codex-nodejs-common",
3
- "version": "0.10.11",
3
+ "version": "0.10.13",
4
4
  "description": "Common code for Codex framework",
5
5
  "main": "lib/src/index.js",
6
6
  "repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
@@ -2,5 +2,5 @@ import { HostConfig } from "./host-config";
2
2
  import { EndpointConfigInterface } from "./endpoint-config.interface";
3
3
  export declare class EndpointConfig extends HostConfig implements EndpointConfigInterface {
4
4
  constructor(host: any, port: string);
5
- get endpoint(): string;
5
+ get endpoint(): any;
6
6
  }
@@ -7,7 +7,15 @@ class EndpointConfig extends host_config_1.HostConfig {
7
7
  super(host, port);
8
8
  }
9
9
  get endpoint() {
10
- return `${this.host}:${this.port}`;
10
+ if (!this.host.includes(",")) {
11
+ return `${this.host}:${this.port}`;
12
+ }
13
+ else {
14
+ return this.host
15
+ .split(",")
16
+ .map((h) => `${h}:${this.port}`)
17
+ .join(",");
18
+ }
11
19
  }
12
20
  }
13
21
  exports.EndpointConfig = EndpointConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-config.js","sourceRoot":"","sources":["../../../src/config/endpoint-config.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAG3C,MAAa,cACX,SAAQ,wBAAU;IAElB,YAAY,IAAI,EAAE,IAAY;QAC5B,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;CACF;AAVD,wCAUC"}
1
+ {"version":3,"file":"endpoint-config.js","sourceRoot":"","sources":["../../../src/config/endpoint-config.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAG3C,MAAa,cACX,SAAQ,wBAAU;IAElB,YAAY,IAAI,EAAE,IAAY;QAC5B,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,IAAI;iBACb,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;iBAC/B,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAjBD,wCAiBC"}
@@ -0,0 +1,6 @@
1
+ import { ArgumentMetadata, PipeTransform } from "@nestjs/common";
2
+ export declare class FloatValidationPipe implements PipeTransform {
3
+ private _schema;
4
+ constructor();
5
+ transform(value: any, metadata: ArgumentMetadata): any;
6
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FloatValidationPipe = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const Joi = require("joi");
15
+ let FloatValidationPipe = class FloatValidationPipe {
16
+ constructor() {
17
+ this._schema = Joi.number();
18
+ }
19
+ transform(value, metadata) {
20
+ const { error } = this._schema.validate(value.data);
21
+ if (error) {
22
+ throw new common_1.BadRequestException(error.message);
23
+ }
24
+ return value;
25
+ }
26
+ };
27
+ exports.FloatValidationPipe = FloatValidationPipe;
28
+ exports.FloatValidationPipe = FloatValidationPipe = __decorate([
29
+ (0, common_1.Injectable)(),
30
+ __metadata("design:paramtypes", [])
31
+ ], FloatValidationPipe);
32
+ //# sourceMappingURL=float.validation.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float.validation.pipe.js","sourceRoot":"","sources":["../../../src/pipe/float.validation.pipe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,2BAA2B;AAGpB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAE9B;QACE,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAEM,SAAS,CAAC,KAAU,EAAE,QAA0B;QACrD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,4BAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAbY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;;GACA,mBAAmB,CAa/B"}
@@ -5,3 +5,5 @@ export * from "./not-empty.pipe";
5
5
  export * from "./joi-http-validation.pipe";
6
6
  export * from "./uuidv4.array.validation.pipe";
7
7
  export * from "./uuidv4.validation.pipe";
8
+ export * from "./integer.validation.pipe";
9
+ export * from "./float.validation.pipe";
@@ -21,4 +21,6 @@ __exportStar(require("./not-empty.pipe"), exports);
21
21
  __exportStar(require("./joi-http-validation.pipe"), exports);
22
22
  __exportStar(require("./uuidv4.array.validation.pipe"), exports);
23
23
  __exportStar(require("./uuidv4.validation.pipe"), exports);
24
+ __exportStar(require("./integer.validation.pipe"), exports);
25
+ __exportStar(require("./float.validation.pipe"), exports);
24
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,6CAA2B;AAC3B,uDAAqC;AACrC,mDAAiC;AACjC,6DAA2C;AAC3C,iEAA+C;AAC/C,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,6CAA2B;AAC3B,uDAAqC;AACrC,mDAAiC;AACjC,6DAA2C;AAC3C,iEAA+C;AAC/C,2DAAyC;AACzC,4DAA0C;AAC1C,0DAAwC"}
@@ -0,0 +1,6 @@
1
+ import { ArgumentMetadata, PipeTransform } from "@nestjs/common";
2
+ export declare class IntegerValidationPipe implements PipeTransform {
3
+ private _schema;
4
+ constructor();
5
+ transform(value: any, metadata: ArgumentMetadata): any;
6
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.IntegerValidationPipe = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const Joi = require("joi");
15
+ let IntegerValidationPipe = class IntegerValidationPipe {
16
+ constructor() {
17
+ this._schema = Joi.number().integer();
18
+ }
19
+ transform(value, metadata) {
20
+ const { error } = this._schema.validate(value.data);
21
+ if (error) {
22
+ throw new common_1.BadRequestException(error.message);
23
+ }
24
+ return value;
25
+ }
26
+ };
27
+ exports.IntegerValidationPipe = IntegerValidationPipe;
28
+ exports.IntegerValidationPipe = IntegerValidationPipe = __decorate([
29
+ (0, common_1.Injectable)(),
30
+ __metadata("design:paramtypes", [])
31
+ ], IntegerValidationPipe);
32
+ //# sourceMappingURL=integer.validation.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integer.validation.pipe.js","sourceRoot":"","sources":["../../../src/pipe/integer.validation.pipe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,2BAA2B;AAGpB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEhC;QACE,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAEM,SAAS,CAAC,KAAU,EAAE,QAA0B;QACrD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,4BAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAbY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;;GACA,qBAAqB,CAajC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptexlabs/codex-nodejs-common",
3
- "version": "0.10.11",
3
+ "version": "0.10.13",
4
4
  "description": "Common code for Codex framework",
5
5
  "main": "lib/src/index.js",
6
6
  "repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
@@ -9,6 +9,13 @@ export class EndpointConfig
9
9
  }
10
10
 
11
11
  get endpoint() {
12
- return `${this.host}:${this.port}`;
12
+ if (!this.host.includes(",")) {
13
+ return `${this.host}:${this.port}`;
14
+ } else {
15
+ return this.host
16
+ .split(",")
17
+ .map((h) => `${h}:${this.port}`)
18
+ .join(",");
19
+ }
13
20
  }
14
21
  }
@@ -0,0 +1,23 @@
1
+ import {
2
+ ArgumentMetadata,
3
+ BadRequestException,
4
+ Injectable,
5
+ PipeTransform,
6
+ } from "@nestjs/common";
7
+ import * as Joi from "joi";
8
+
9
+ @Injectable()
10
+ export class FloatValidationPipe implements PipeTransform {
11
+ private _schema: Joi.Schema;
12
+ constructor() {
13
+ this._schema = Joi.number();
14
+ }
15
+
16
+ public transform(value: any, metadata: ArgumentMetadata): any {
17
+ const { error } = this._schema.validate(value.data);
18
+ if (error) {
19
+ throw new BadRequestException(error.message);
20
+ }
21
+ return value;
22
+ }
23
+ }
package/src/pipe/index.ts CHANGED
@@ -5,3 +5,5 @@ export * from "./not-empty.pipe";
5
5
  export * from "./joi-http-validation.pipe";
6
6
  export * from "./uuidv4.array.validation.pipe";
7
7
  export * from "./uuidv4.validation.pipe";
8
+ export * from "./integer.validation.pipe";
9
+ export * from "./float.validation.pipe";
@@ -0,0 +1,23 @@
1
+ import {
2
+ ArgumentMetadata,
3
+ BadRequestException,
4
+ Injectable,
5
+ PipeTransform,
6
+ } from "@nestjs/common";
7
+ import * as Joi from "joi";
8
+
9
+ @Injectable()
10
+ export class IntegerValidationPipe implements PipeTransform {
11
+ private _schema: Joi.Schema;
12
+ constructor() {
13
+ this._schema = Joi.number().integer();
14
+ }
15
+
16
+ public transform(value: any, metadata: ArgumentMetadata): any {
17
+ const { error } = this._schema.validate(value.data);
18
+ if (error) {
19
+ throw new BadRequestException(error.message);
20
+ }
21
+ return value;
22
+ }
23
+ }