@nmxjs/api 1.1.18 → 1.1.20

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.
@@ -13,6 +13,7 @@ const common_1 = require("@nestjs/common");
13
13
  const constants_1 = require("./constants");
14
14
  const Services = require("./services");
15
15
  const constants_2 = require("./constants");
16
+ const TcpTransport_1 = require("../TcpTransport");
16
17
  const NatsTransport_1 = require("../NatsTransport");
17
18
  const GrpcTransport_1 = require("../GrpcTransport");
18
19
  let ApiServiceModule = class ApiServiceModule {
@@ -21,7 +22,7 @@ exports.ApiServiceModule = ApiServiceModule;
21
22
  exports.ApiServiceModule = ApiServiceModule = __decorate([
22
23
  (0, common_1.Global)(),
23
24
  (0, common_1.Module)({
24
- imports: [GrpcTransport_1.GrpcTransportModule, NatsTransport_1.NatsTransportModule],
25
+ imports: [TcpTransport_1.TcpTransportModule, GrpcTransport_1.GrpcTransportModule, NatsTransport_1.NatsTransportModule],
25
26
  providers: [
26
27
  ...Object.values(Services),
27
28
  {
@@ -43,7 +44,7 @@ exports.ApiServiceModule = ApiServiceModule = __decorate([
43
44
  }
44
45
  return strategy;
45
46
  },
46
- inject: [config_1.configKey, GrpcTransport_1.grpcTransportStrategyKey, NatsTransport_1.natsTransportStrategyKey],
47
+ inject: [config_1.configKey, TcpTransport_1.tcpTransportStrategyKey, GrpcTransport_1.grpcTransportStrategyKey, NatsTransport_1.natsTransportStrategyKey],
47
48
  },
48
49
  ],
49
50
  exports: [constants_1.apiServiceFactoryKey],
@@ -1 +1 @@
1
- {"version":3,"file":"ApiServiceModule.js","sourceRoot":"","sources":["../../src/ApiService/ApiServiceModule.ts"],"names":[],"mappings":";;;;;;;;;AAAA,0CAA8C;AAC9C,0CAAmD;AACnD,2CAAgD;AAEhD,2CAAmD;AACnD,uCAAuC;AAEvC,2CAAmD;AACnD,oDAAiF;AACjF,oDAAiF;AAiC1E,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;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ices_1.Transport.GRPC,
34
34
  options: {
35
- url: `${serviceInfo.host || '127.0.0.1'}:${serviceInfo.port || 6000}`,
35
+ url: `${serviceInfo.host || '127.0.0.1'}:${serviceInfo.port || 3000}`,
36
36
  package: [packageName],
37
37
  protoPath: [protoPath],
38
38
  keepalive: {
@@ -45,9 +45,9 @@ let CreateApiService = class CreateApiService {
45
45
  return res;
46
46
  }, {});
47
47
  return {
48
- serviceName: options.service,
49
- options: natsOptions,
50
48
  service,
49
+ options: natsOptions,
50
+ serviceName: options.service,
51
51
  };
52
52
  }
53
53
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CreateApiService.js","sourceRoot":"","sources":["../../../src/NatsTransport/services/CreateApiService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,yDAAmF;AACnF,2CAAoD;AAEpD,0CAAmD;AAI5C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAG3B,YAA+B,MAAkC;QAAf,WAAM,GAAN,MAAM,CAAS;QAF9C,YAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAES,CAAC;IAE9D,KAAK,CAAC,IAAI,CAAC,OAAiC;QACjD,MAAM,WAAW,GAAgB;YAC/B,SAAS,EAAE,yBAAS,CAAC,IAAI;YACzB,OAAO,kBACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,WAAW,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IACzG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC1G;SACF,CAAC;QAEF,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CA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AAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;YACrE,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,IAAI,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;YACtG,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO;YACL,OAAO;YACP,OAAO,EAAE,WAAW;YACpB,WAAW,EAAE,OAAO,CAAC,OAAO;SAC7B,CAAC;IACJ,CAAC;CACF,CAAA;AAzCY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAIE,WAAA,IAAA,eAAM,EAAC,kBAAS,CAAC,CAAA;;GAHnB,gBAAgB,CAyC5B"}
@@ -0,0 +1,2 @@
1
+ export declare class TcpTransportModule {
2
+ }
@@ -0,0 +1,33 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TcpTransportModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const constants_1 = require("./constants");
12
+ const config_1 = require("@nmxjs/config");
13
+ const Services = require("./services");
14
+ let TcpTransportModule = class TcpTransportModule {
15
+ };
16
+ exports.TcpTransportModule = TcpTransportModule;
17
+ exports.TcpTransportModule = TcpTransportModule = __decorate([
18
+ (0, common_1.Module)({
19
+ providers: [
20
+ ...Object.values(Services),
21
+ {
22
+ provide: constants_1.tcpTransportStrategyKey,
23
+ useFactory: (createApiService) => ({
24
+ type: config_1.TransporterEnumType.TCP,
25
+ createService: createApiService.call.bind(createApiService),
26
+ }),
27
+ inject: [Services.CreateApiService],
28
+ },
29
+ ],
30
+ exports: [constants_1.tcpTransportStrategyKey],
31
+ })
32
+ ], TcpTransportModule);
33
+ //# sourceMappingURL=TcpTransportModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TcpTransportModule.js","sourceRoot":"","sources":["../../src/TcpTransport/TcpTransportModule.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAAsD;AAEtD,0CAAoD;AACpD,uCAAuC;AAgBhC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAd9B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC1B;gBACE,OAAO,EAAE,mCAAuB;gBAChC,UAAU,EAAE,CAAC,gBAA2C,EAAsB,EAAE,CAAC,CAAC;oBAChF,IAAI,EAAE,4BAAmB,CAAC,GAAG;oBAC7B,aAAa,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;iBAC5D,CAAC;gBACF,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;aACpC;SACF;QACD,OAAO,EAAE,CAAC,mCAAuB,CAAC;KACnC,CAAC;GACW,kBAAkB,CAAG"}
@@ -0,0 +1 @@
1
+ export * from './tcpTransportStrategyKey';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tcpTransportStrategyKey"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/TcpTransport/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C"}
@@ -0,0 +1 @@
1
+ export declare const tcpTransportStrategyKey: unique symbol;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tcpTransportStrategyKey = void 0;
4
+ exports.tcpTransportStrategyKey = Symbol('TPC_TRANSPORT_STRATEGY_KEY');
5
+ //# sourceMappingURL=tcpTransportStrategyKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcpTransportStrategyKey.js","sourceRoot":"","sources":["../../../src/TcpTransport/constants/tcpTransportStrategyKey.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './constants';
2
+ export * from './TcpTransportModule';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./TcpTransportModule"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/TcpTransport/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,uDAAqC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="types" />
2
+ import { IConfig } from '@nmxjs/config';
3
+ import type { ICreateApiServiceOptions, IApiServiceWithInfo } from '../../ApiService';
4
+ export declare class CreateApiService {
5
+ protected readonly config: IConfig;
6
+ constructor(config: IConfig);
7
+ call(options: ICreateApiServiceOptions): Promise<IApiServiceWithInfo>;
8
+ }
@@ -0,0 +1,53 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CreateApiService = void 0;
16
+ const microservices_1 = require("@nestjs/microservices");
17
+ const common_1 = require("@nestjs/common");
18
+ const config_1 = require("@nmxjs/config");
19
+ let CreateApiService = class CreateApiService {
20
+ constructor(config) {
21
+ this.config = config;
22
+ }
23
+ async call(options) {
24
+ const serviceInfo = this.config.transport.services.find(v => v.name === options.service);
25
+ if (!serviceInfo) {
26
+ return;
27
+ }
28
+ const tcpOptions = {
29
+ transport: microservices_1.Transport.TCP,
30
+ options: {
31
+ host: serviceInfo.host || '127.0.0.1',
32
+ port: serviceInfo.port || 3000,
33
+ },
34
+ };
35
+ const client = microservices_1.ClientProxyFactory.create(tcpOptions);
36
+ const service = Object.keys(options.schema).reduce((res, methodName) => {
37
+ res[methodName] = data => client.send(`${options.subService || options.service}.${methodName}`, data);
38
+ return res;
39
+ }, {});
40
+ return {
41
+ service,
42
+ options: tcpOptions,
43
+ serviceName: options.service,
44
+ };
45
+ }
46
+ };
47
+ exports.CreateApiService = CreateApiService;
48
+ exports.CreateApiService = CreateApiService = __decorate([
49
+ (0, common_1.Injectable)(),
50
+ __param(0, (0, common_1.Inject)(config_1.configKey)),
51
+ __metadata("design:paramtypes", [Object])
52
+ ], CreateApiService);
53
+ //# sourceMappingURL=CreateApiService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateApiService.js","sourceRoot":"","sources":["../../../src/TcpTransport/services/CreateApiService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yDAAwF;AACxF,2CAAoD;AACpD,0CAAmD;AAI5C,IAAM,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@ -0,0 +1 @@
1
+ export * from './CreateApiService';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CreateApiService"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/TcpTransport/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nmxjs/api",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",