fiscalia_bo-nest-helpers 0.0.4 → 0.0.6

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.
Files changed (82) hide show
  1. package/README.md +38 -0
  2. package/dist/app.controller.d.ts +12 -0
  3. package/dist/app.controller.js +63 -0
  4. package/dist/app.controller.js.map +1 -0
  5. package/dist/app.module.d.ts +2 -0
  6. package/dist/app.module.js +34 -0
  7. package/dist/app.module.js.map +1 -0
  8. package/dist/app.service.d.ts +6 -0
  9. package/dist/app.service.js +28 -0
  10. package/dist/app.service.js.map +1 -0
  11. package/dist/configurations/configuration.d.ts +6 -0
  12. package/dist/configurations/configuration.js +9 -0
  13. package/dist/configurations/configuration.js.map +1 -0
  14. package/dist/helpers/global-exception.filter.d.ts +13 -0
  15. package/dist/helpers/global-exception.filter.js +68 -0
  16. package/dist/helpers/global-exception.filter.js.map +1 -0
  17. package/dist/helpers/package-json.helper.d.ts +1 -0
  18. package/dist/helpers/package-json.helper.js +8 -0
  19. package/dist/helpers/package-json.helper.js.map +1 -0
  20. package/dist/helpers/request.helper.js.map +1 -0
  21. package/dist/index.d.ts +8 -1
  22. package/dist/index.js +10 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/main.d.ts +1 -0
  25. package/dist/main.js +42 -0
  26. package/dist/main.js.map +1 -0
  27. package/dist/ms-redis/datapass.interceptor.d.ts +11 -0
  28. package/dist/ms-redis/datapass.interceptor.js +158 -0
  29. package/dist/ms-redis/datapass.interceptor.js.map +1 -0
  30. package/dist/ms-redis/dto/cache.dto.d.ts +12 -0
  31. package/dist/ms-redis/dto/cache.dto.js +87 -0
  32. package/dist/ms-redis/dto/cache.dto.js.map +1 -0
  33. package/dist/ms-redis/dto/cache.options.dto.d.ts +6 -0
  34. package/dist/ms-redis/dto/cache.options.dto.js +7 -0
  35. package/dist/ms-redis/dto/cache.options.dto.js.map +1 -0
  36. package/dist/ms-redis/ms-redis.module.d.ts +11 -0
  37. package/dist/ms-redis/ms-redis.module.js +71 -0
  38. package/dist/ms-redis/ms-redis.module.js.map +1 -0
  39. package/dist/ms-redis/ms-redis.service.d.ts +14 -0
  40. package/dist/ms-redis/ms-redis.service.js +74 -0
  41. package/dist/ms-redis/ms-redis.service.js.map +1 -0
  42. package/dist/ms-redis/request.proto +18 -0
  43. package/dist/ms-seguridad/Seguridad.pb.d.ts +57 -0
  44. package/dist/ms-seguridad/Seguridad.pb.js +23 -0
  45. package/dist/ms-seguridad/Seguridad.pb.js.map +1 -0
  46. package/dist/ms-seguridad/Seguridad.proto +60 -0
  47. package/dist/ms-seguridad/ms-seguridad.decorator.d.ts +11 -0
  48. package/dist/ms-seguridad/ms-seguridad.decorator.js +36 -0
  49. package/dist/ms-seguridad/ms-seguridad.decorator.js.map +1 -0
  50. package/dist/ms-seguridad/ms-seguridad.module.d.ts +13 -0
  51. package/dist/ms-seguridad/ms-seguridad.module.js +80 -0
  52. package/dist/ms-seguridad/ms-seguridad.module.js.map +1 -0
  53. package/dist/ms-seguridad/ms-seguridad.service.d.ts +15 -0
  54. package/dist/ms-seguridad/ms-seguridad.service.js +58 -0
  55. package/dist/ms-seguridad/ms-seguridad.service.js.map +1 -0
  56. package/dist/ms-seguridad/permision.guard.d.ts +13 -0
  57. package/dist/ms-seguridad/permision.guard.js +51 -0
  58. package/dist/ms-seguridad/permision.guard.js.map +1 -0
  59. package/dist/ms-seguridad/token-auth.guard.d.ts +7 -0
  60. package/dist/ms-seguridad/token-auth.guard.js +42 -0
  61. package/dist/ms-seguridad/token-auth.guard.js.map +1 -0
  62. package/dist/{src/services → services}/ms-files.service.js +1 -2
  63. package/dist/services/ms-files.service.js.map +1 -0
  64. package/dist/tsconfig.build.tsbuildinfo +1 -0
  65. package/dist/types/index.js.map +1 -0
  66. package/dist/{src/types → types}/input.type.js.map +1 -1
  67. package/dist/types/response.type.js.map +1 -0
  68. package/package.json +31 -7
  69. package/dist/src/helpers/request.helper.js.map +0 -1
  70. package/dist/src/services/ms-files.service.js.map +0 -1
  71. package/dist/src/types/index.js.map +0 -1
  72. package/dist/src/types/response.type.js.map +0 -1
  73. package/dist/tsconfig.tsbuildinfo +0 -1
  74. /package/dist/{src/helpers → helpers}/request.helper.d.ts +0 -0
  75. /package/dist/{src/helpers → helpers}/request.helper.js +0 -0
  76. /package/dist/{src/services → services}/ms-files.service.d.ts +0 -0
  77. /package/dist/{src/types → types}/index.d.ts +0 -0
  78. /package/dist/{src/types → types}/index.js +0 -0
  79. /package/dist/{src/types → types}/input.type.d.ts +0 -0
  80. /package/dist/{src/types → types}/input.type.js +0 -0
  81. /package/dist/{src/types → types}/response.type.d.ts +0 -0
  82. /package/dist/{src/types → types}/response.type.js +0 -0
package/README.md CHANGED
@@ -42,6 +42,44 @@ import { MsFilesService } from 'fiscalia_bo-nest-helpers';
42
42
  ENV_SERVICE_MS_FILES='https://ms-files.url'
43
43
  ```
44
44
 
45
+ # USO DEL MODULO `MS-SEGURIDAD`
46
+
47
+ El módulo MsSeguridadModule proporciona una manera fácil de comunicarse con un servicio de seguridad a través de gRPC.
48
+
49
+ ## Servicios disponibles
50
+
51
+ - MsSeguridadModule
52
+ - MsSeguridadService
53
+
54
+ ## Configuración
55
+
56
+ Antes de utilizar el módulo, asegúrese de tener las siguientes variables de entorno configuradas:
57
+
58
+ - `ENV_GRPC_MS_SEGURIDAD`: la URL del servidor de seguridad a través de gRPC.
59
+
60
+ ## Uso
61
+
62
+ Para utilizar el módulo, primero importe `MsSeguridadModule` en su módulo principal:
63
+
64
+ ```typescript
65
+ import { Module } from '@nestjs/common';
66
+ import { MsSeguridadModule } from 'fiscalia_bo-nest-helpers/seguridad';
67
+
68
+ @Module({
69
+ imports: [
70
+ ConfigModule.forRoot({ isGlobal: true }),
71
+ MsSeguridadModule.register({ url: process.env.ENV_GRPC_MS_SEGURIDAD || '' }),
72
+ ],
73
+ controllers: [],
74
+ providers: [],
75
+ })
76
+ export class AppModule {}
77
+ ```
78
+
79
+ > **NOTA IMPORTANTE:** previo al uso del modulO debe importarse el [`ConfigModule`](https://docs.nestjs.com/techniques/configuration#getting-started "Nestjs Docs") de nestjs y configurarlo para uso global
80
+
81
+ En este ejemplo, estamos utilizando el método register para cargar la configuración de forma `síncrona`
82
+
45
83
  ## Información
46
84
 
47
85
  - Author - [UTIC](mailto:informatica@fiscalia.gob.bo)
@@ -0,0 +1,12 @@
1
+ import { AppService } from './app.service';
2
+ import { UserPayload } from './ms-seguridad/ms-seguridad.decorator';
3
+ declare class TokenBody {
4
+ token: string;
5
+ }
6
+ export declare class AppController {
7
+ private readonly appService;
8
+ constructor(appService: AppService);
9
+ getHello(): string;
10
+ test(body: TokenBody, user: UserPayload, token: string, permissions: string[], res: any): Promise<void>;
11
+ }
12
+ export {};
@@ -0,0 +1,63 @@
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.AppController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const app_service_1 = require("./app.service");
18
+ const swagger_1 = require("@nestjs/swagger");
19
+ const ms_seguridad_decorator_1 = require("./ms-seguridad/ms-seguridad.decorator");
20
+ class TokenBody {
21
+ }
22
+ __decorate([
23
+ (0, swagger_1.ApiProperty)(),
24
+ __metadata("design:type", String)
25
+ ], TokenBody.prototype, "token", void 0);
26
+ let AppController = class AppController {
27
+ constructor(appService) {
28
+ this.appService = appService;
29
+ }
30
+ getHello() {
31
+ return this.appService.getHello();
32
+ }
33
+ async test(body, user, token, permissions, res) {
34
+ return;
35
+ }
36
+ };
37
+ __decorate([
38
+ (0, common_1.Get)(),
39
+ __metadata("design:type", Function),
40
+ __metadata("design:paramtypes", []),
41
+ __metadata("design:returntype", String)
42
+ ], AppController.prototype, "getHello", null);
43
+ __decorate([
44
+ (0, swagger_1.ApiTags)('seguridad'),
45
+ (0, common_1.Post)('test-seguridad'),
46
+ (0, ms_seguridad_decorator_1.BearerAuthPermision)(),
47
+ (0, swagger_1.ApiConsumes)('application/json'),
48
+ __param(0, (0, common_1.Body)()),
49
+ __param(1, (0, ms_seguridad_decorator_1.AuthUser)()),
50
+ __param(2, (0, ms_seguridad_decorator_1.AuthToken)()),
51
+ __param(3, (0, ms_seguridad_decorator_1.AuthPermissions)()),
52
+ __param(4, (0, common_1.Res)({ passthrough: true })),
53
+ __metadata("design:type", Function),
54
+ __metadata("design:paramtypes", [TokenBody,
55
+ ms_seguridad_decorator_1.UserPayload, String, Array, Object]),
56
+ __metadata("design:returntype", Promise)
57
+ ], AppController.prototype, "test", null);
58
+ AppController = __decorate([
59
+ (0, common_1.Controller)(),
60
+ __metadata("design:paramtypes", [app_service_1.AppService])
61
+ ], AppController);
62
+ exports.AppController = AppController;
63
+ //# sourceMappingURL=app.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkE;AAClE,+CAA2C;AAC3C,6CAAoE;AACpE,kFAM+C;AAE/C,MAAM,SAAS;CAGd;AAFC;IAAC,IAAA,qBAAW,GAAE;;wCACA;AAIT,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGvD,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IASK,AAAN,KAAK,CAAC,IAAI,CACA,IAAe,EACX,IAAiB,EAChB,KAAa,EACP,WAAqB,EACZ,GAAG;QAO/B,OAAO;IACT,CAAC;CACF,CAAA;AA1BC;IAAC,IAAA,YAAG,GAAE;;;;6CAGL;AASK;IAJL,IAAA,iBAAO,EAAC,WAAW,CAAC;IACpB,IAAA,aAAI,EAAC,gBAAgB,CAAC;IACtB,IAAA,4CAAmB,GAAE;IACrB,IAAA,qBAAW,EAAC,kBAAkB,CAAC;IAE7B,WAAA,IAAA,aAAI,GAAE,CAAA;IACN,WAAA,IAAA,iCAAQ,GAAE,CAAA;IACV,WAAA,IAAA,kCAAS,GAAE,CAAA;IACX,WAAA,IAAA,wCAAe,GAAE,CAAA;IACjB,WAAA,IAAA,YAAG,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;;qCAJb,SAAS;QACL,oCAAW;;yCAW9B;AA5BU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CA6BzB;AA7BY,sCAAa"}
@@ -0,0 +1,2 @@
1
+ export declare class AppModule {
2
+ }
@@ -0,0 +1,34 @@
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.AppModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const app_controller_1 = require("./app.controller");
12
+ const app_service_1 = require("./app.service");
13
+ const config_1 = require("@nestjs/config");
14
+ const ms_seguridad_module_1 = require("./ms-seguridad/ms-seguridad.module");
15
+ const ms_redis_module_1 = require("./ms-redis/ms-redis.module");
16
+ const configuration_1 = require("./configurations/configuration");
17
+ let AppModule = class AppModule {
18
+ };
19
+ AppModule = __decorate([
20
+ (0, common_1.Module)({
21
+ imports: [
22
+ config_1.ConfigModule.forRoot({ load: [configuration_1.default], isGlobal: true }),
23
+ ms_seguridad_module_1.MsSeguridadModule.register({
24
+ urlSeguridad: process.env.ENV_GRPC_MS_SEGURIDAD,
25
+ urlRedisCache: process.env.ENV_GRPC_MS_REDIS_CACHE,
26
+ }),
27
+ ms_redis_module_1.MsRedisModule.register({ urlRedisCache: process.env.ENV_GRPC_MS_REDIS_CACHE || '' }),
28
+ ],
29
+ controllers: [app_controller_1.AppController],
30
+ providers: [app_service_1.AppService],
31
+ })
32
+ ], AppModule);
33
+ exports.AppModule = AppModule;
34
+ //# sourceMappingURL=app.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,2CAA6D;AAC7D,4EAAuE;AACvE,gEAA2D;AAC3D,kEAA2D;AAcpD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAZrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,uBAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC/D,uCAAiB,CAAC,QAAQ,CAAC;gBACzB,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;gBAC/C,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB;aACnD,CAAC;YACF,+BAAa,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,EAAE,EAAE,CAAC;SACrF;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
@@ -0,0 +1,6 @@
1
+ import { MsSeguridadService } from './ms-seguridad/ms-seguridad.service';
2
+ export declare class AppService {
3
+ private readonly seguridadService;
4
+ constructor(seguridadService: MsSeguridadService);
5
+ getHello(): string;
6
+ }
@@ -0,0 +1,28 @@
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.AppService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const ms_seguridad_service_1 = require("./ms-seguridad/ms-seguridad.service");
15
+ let AppService = class AppService {
16
+ constructor(seguridadService) {
17
+ this.seguridadService = seguridadService;
18
+ }
19
+ getHello() {
20
+ return 'Hello World!';
21
+ }
22
+ };
23
+ AppService = __decorate([
24
+ (0, common_1.Injectable)(),
25
+ __metadata("design:paramtypes", [ms_seguridad_service_1.MsSeguridadService])
26
+ ], AppService);
27
+ exports.AppService = AppService;
28
+ //# sourceMappingURL=app.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,8EAAyE;AAGlE,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YAA6B,gBAAoC;QAApC,qBAAgB,GAAhB,gBAAgB,CAAoB;IAAG,CAAC;IAErE,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAA;AANY,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAEoC,yCAAkB;GADtD,UAAU,CAMtB;AANY,gCAAU"}
@@ -0,0 +1,6 @@
1
+ declare const _default: () => {
2
+ packageJson: any;
3
+ port: number;
4
+ appMaxSize: string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ exports.default = () => ({
5
+ packageJson: require((0, path_1.join)(process.cwd(), 'package.json')),
6
+ port: parseInt(process.env.ENV_PORT, 10) || 8001,
7
+ appMaxSize: process.env.ENV_FILE_MAX_SIZE || '100mb',
8
+ });
9
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configurations/configuration.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAE5B,kBAAe,GAAG,EAAE,CAAC,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACzD,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,IAAI;IAChD,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO;CAGrD,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { ExceptionFilter, ArgumentsHost, BadRequestException, HttpException, NotAcceptableException } from '@nestjs/common';
2
+ export declare class GlobalExceptionFilter implements ExceptionFilter {
3
+ catch(error: Error, host: ArgumentsHost): void;
4
+ }
5
+ export declare class CustomHttpError extends HttpException {
6
+ constructor(message?: string, status?: number, response?: any, error?: boolean);
7
+ }
8
+ export declare class ApiBadRequestError extends BadRequestException {
9
+ constructor(message?: string, status?: number, response?: any, error?: boolean);
10
+ }
11
+ export declare class NotAcceptableError extends NotAcceptableException {
12
+ constructor(message?: string, status?: number, response?: any, error?: boolean);
13
+ }
@@ -0,0 +1,68 @@
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.NotAcceptableError = exports.ApiBadRequestError = exports.CustomHttpError = exports.GlobalExceptionFilter = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let GlobalExceptionFilter = class GlobalExceptionFilter {
12
+ catch(error, host) {
13
+ const response = host.switchToHttp().getResponse();
14
+ let resp = {
15
+ error: true,
16
+ message: 'Error interno del servidor',
17
+ response: null,
18
+ status: 500,
19
+ };
20
+ if (error instanceof common_1.BadRequestException) {
21
+ resp.message = `Excepción de solicitud incorrecta, ${error.getResponse().message}`;
22
+ resp.status = 400;
23
+ }
24
+ else if (error instanceof common_1.NotFoundException) {
25
+ resp.message = 'No encontrado';
26
+ resp.status = 404;
27
+ }
28
+ else if (error instanceof common_1.UnprocessableEntityException) {
29
+ resp.message = 'Entidad no processable';
30
+ resp.status = 422;
31
+ }
32
+ else if (error instanceof common_1.HttpException) {
33
+ const respErr = error.getResponse();
34
+ if (typeof (respErr === null || respErr === void 0 ? void 0 : respErr.error) !== 'boolean' && typeof (respErr === null || respErr === void 0 ? void 0 : respErr.message) !== 'string') {
35
+ if (typeof respErr === 'string')
36
+ response.message = respErr;
37
+ }
38
+ else
39
+ resp = respErr;
40
+ if (!resp.status || resp.status < 200)
41
+ resp.status = 400;
42
+ }
43
+ response.status(resp.status).json(resp);
44
+ }
45
+ };
46
+ GlobalExceptionFilter = __decorate([
47
+ (0, common_1.Catch)()
48
+ ], GlobalExceptionFilter);
49
+ exports.GlobalExceptionFilter = GlobalExceptionFilter;
50
+ class CustomHttpError extends common_1.HttpException {
51
+ constructor(message = 'Ocurrio un error', status = 400, response = null, error = true) {
52
+ super({ error, message, status, response }, status);
53
+ }
54
+ }
55
+ exports.CustomHttpError = CustomHttpError;
56
+ class ApiBadRequestError extends common_1.BadRequestException {
57
+ constructor(message = 'Ocurrio un error', status = 400, response = null, error = true) {
58
+ super({ error, message, status, response });
59
+ }
60
+ }
61
+ exports.ApiBadRequestError = ApiBadRequestError;
62
+ class NotAcceptableError extends common_1.NotAcceptableException {
63
+ constructor(message = 'no es posible devolver datos por un error', status = 406, response = null, error = true) {
64
+ super({ error, message, status, response });
65
+ }
66
+ }
67
+ exports.NotAcceptableError = NotAcceptableError;
68
+ //# sourceMappingURL=global-exception.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../../src/helpers/global-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CASwB;AAIjB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,KAAK,CAAC,KAAY,EAAE,IAAmB;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;QACnD,IAAI,IAAI,GAAqB;YAC3B,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,4BAA4B;YACrC,QAAQ,EAAE,IAAI;YACd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BAAkB,EAAE,MAAM,GAAG,GAAG,EAAE,QAAQ,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI;QACnF,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF;AAJD,0CAIC;AAKD,MAAa,kBAAmB,SAAQ,4BAAmB;IACzD,YAAY,OAAO,GAAG,kBAAkB,EAAE,MAAM,GAAG,GAAG,EAAE,QAAQ,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI;QACnF,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9C,CAAC;CACF;AAJD,gDAIC;AAKD,MAAa,kBAAmB,SAAQ,+BAAsB;IAC5D,YACE,OAAO,GAAG,2CAA2C,EACrD,MAAM,GAAG,GAAG,EACZ,QAAQ,GAAG,IAAI,EACf,KAAK,GAAG,IAAI;QAEZ,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9C,CAAC;CACF;AATD,gDASC"}
@@ -0,0 +1 @@
1
+ export declare const nameParsePresentation: (name: string) => string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nameParsePresentation = void 0;
4
+ const nameParsePresentation = (name) => {
5
+ return name.toUpperCase().replace(/-/g, ' ');
6
+ };
7
+ exports.nameParsePresentation = nameParsePresentation;
8
+ //# sourceMappingURL=package-json.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json.helper.js","sourceRoot":"","sources":["../../src/helpers/package-json.helper.ts"],"names":[],"mappings":";;;AAKO,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC5D,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC/C,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AQ,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;iBAC/C;aACF;iBAAM;gBACL,QAAQ,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;aAClC;SACF;aAAM;YACL,QAAQ,CAAC,QAAQ,GAAG,GAAG,CAAC;SACzB;IACH,CAAC,CAAC,CAAC;IACL,OAAO,QAAQ,CAAC;AAClB,CAAC;AAxCD,kCAwCC;AAQD,SAAgB,cAAc,CAAC,OAAe,EAAE,gBAA8C,EAAE;IAO9F,MAAM,iBAAiB,GAAG,CACxB,IAAiB,EACjB,UAAe,EAAE,EACe,EAAE;QAClC,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,kCAAO,aAAa,GAAK,OAAO,EAAG,CAAC;IACtE,CAAC,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAdD,wCAcC"}
package/dist/index.d.ts CHANGED
@@ -1 +1,8 @@
1
- export * from './src/services/ms-files.service';
1
+ export * from './services/ms-files.service';
2
+ export * from './ms-redis/ms-redis.module';
3
+ export * from './ms-redis/ms-redis.service';
4
+ export * from './ms-redis/datapass.interceptor';
5
+ export * from './ms-seguridad/ms-seguridad.module';
6
+ export * from './ms-seguridad/ms-seguridad.service';
7
+ export { PermissionsGuard } from './ms-seguridad/permision.guard';
8
+ export * from './ms-seguridad/token-auth.guard';
package/dist/index.js CHANGED
@@ -14,5 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./src/services/ms-files.service"), exports);
17
+ exports.PermissionsGuard = void 0;
18
+ __exportStar(require("./services/ms-files.service"), exports);
19
+ __exportStar(require("./ms-redis/ms-redis.module"), exports);
20
+ __exportStar(require("./ms-redis/ms-redis.service"), exports);
21
+ __exportStar(require("./ms-redis/datapass.interceptor"), exports);
22
+ __exportStar(require("./ms-seguridad/ms-seguridad.module"), exports);
23
+ __exportStar(require("./ms-seguridad/ms-seguridad.service"), exports);
24
+ var permision_guard_1 = require("./ms-seguridad/permision.guard");
25
+ Object.defineProperty(exports, "PermissionsGuard", { enumerable: true, get: function () { return permision_guard_1.PermissionsGuard; } });
26
+ __exportStar(require("./ms-seguridad/token-auth.guard"), exports);
18
27
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8DAA4C;AAE5C,6DAA2C;AAC3C,8DAA4C;AAC5C,kEAAgD;AAEhD,qEAAmD;AACnD,sEAAoD;AACpD,kEAAkE;AAAzD,mHAAA,gBAAgB,OAAA;AACzB,kEAAgD"}
package/dist/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/main.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@nestjs/core");
4
+ const config_1 = require("@nestjs/config");
5
+ const common_1 = require("@nestjs/common");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ const package_json_helper_1 = require("./helpers/package-json.helper");
8
+ const app_module_1 = require("./app.module");
9
+ const chalk_1 = require("chalk");
10
+ const path_1 = require("path");
11
+ async function bootstrap() {
12
+ const app = await core_1.NestFactory.create(app_module_1.AppModule);
13
+ app.enableVersioning({ type: common_1.VersioningType.URI });
14
+ app.useStaticAssets((0, path_1.join)(__dirname, '..', 'public'));
15
+ const envService = app.get(config_1.ConfigService);
16
+ const packageJson = envService.get('packageJson');
17
+ if (envService.get('ENV_ENTORNO') !== 'production') {
18
+ const config = new swagger_1.DocumentBuilder()
19
+ .setTitle((0, package_json_helper_1.nameParsePresentation)(packageJson.name))
20
+ .setVersion(packageJson.version)
21
+ .setDescription(packageJson.description)
22
+ .setContact(packageJson.contact.name, '', packageJson.contact.email)
23
+ .addBearerAuth()
24
+ .build();
25
+ const document = swagger_1.SwaggerModule.createDocument(app, config);
26
+ swagger_1.SwaggerModule.setup('api', app, document, {
27
+ customSiteTitle: (0, package_json_helper_1.nameParsePresentation)(packageJson.name),
28
+ customfavIcon: '../assets/images/favicon.ico',
29
+ customCss: `
30
+ .swagger-ui .topbar { display: none; }
31
+ .swagger-ui .info { margin: 20px 0;}
32
+ .swagger-ui .info hgroup.main { margin: 0 0 0;}
33
+ .title span { display: block; }
34
+ `,
35
+ });
36
+ }
37
+ await app.listen(3010, '0.0.0.0').then(async () => {
38
+ console.log(chalk_1.bold.blue('🚀 API is listening ON PORT', (await app.getUrl()) + '/api'));
39
+ });
40
+ }
41
+ bootstrap();
42
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAA+C;AAC/C,2CAAgD;AAEhD,6CAAiE;AACjE,uEAAsE;AACtE,6CAAyC;AACzC,iCAA6B;AAC7B,+BAA4B;AAE5B,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAyB,sBAAS,CAAC,CAAC;IACxE,GAAG,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,uBAAc,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,GAAG,CAAC,eAAe,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAGrD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,sBAAa,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAElD,IAAI,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,YAAY,EAAE;QAClD,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE;aACjC,QAAQ,CAAC,IAAA,2CAAqB,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aACjD,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC;aAC/B,cAAc,CAAC,WAAW,CAAC,WAAW,CAAC;aACvC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;aACnE,aAAa,EAAE;aACf,KAAK,EAAE,CAAC;QAEX,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC3D,uBAAa,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE;YACxC,eAAe,EAAE,IAAA,2CAAqB,EAAC,WAAW,CAAC,IAAI,CAAC;YACxD,aAAa,EAAE,8BAA8B;YAC7C,SAAS,EAAE;;;;;KAKZ;SACA,CAAC,CAAC;KACJ;IAED,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;QAChD,OAAO,CAAC,GAAG,CAAC,YAAI,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACL,CAAC;AACD,SAAS,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { CallHandler, ExecutionContext, NestInterceptor, OnModuleInit } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ import 'reflect-metadata';
4
+ import { ClientGrpc } from '@nestjs/microservices';
5
+ export declare class DatapassInterceptor implements NestInterceptor, OnModuleInit {
6
+ private readonly client;
7
+ private cacheService;
8
+ constructor(client: ClientGrpc);
9
+ onModuleInit(): void;
10
+ intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>>;
11
+ }
@@ -0,0 +1,158 @@
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.DatapassInterceptor = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const rxjs_1 = require("rxjs");
18
+ const operators_1 = require("rxjs/operators");
19
+ const class_validator_1 = require("class-validator");
20
+ require("reflect-metadata");
21
+ const class_transformer_1 = require("class-transformer");
22
+ const decorators_1 = require("@nestjs/common/decorators");
23
+ const cache_dto_1 = require("./dto/cache.dto");
24
+ const parseErrorReturn = (responseHttp, response, responseError) => {
25
+ if (!responseHttp) {
26
+ return (0, rxjs_1.throwError)(responseError);
27
+ }
28
+ else {
29
+ response.status(common_1.HttpStatus.BAD_REQUEST).json(responseError);
30
+ return (0, rxjs_1.throwError)(new common_1.HttpException(responseError, common_1.HttpStatus.BAD_REQUEST));
31
+ }
32
+ };
33
+ const parseResponseReturn = (responseHttp, response, dataCache, dataResponse) => {
34
+ if (responseHttp) {
35
+ response
36
+ .status(common_1.HttpStatus.OK)
37
+ .json(dataCache.keyResponse ? { [dataCache.keyResponse]: dataResponse } : dataResponse);
38
+ }
39
+ else {
40
+ return dataCache.keyResponse ? { [dataCache.keyResponse]: dataResponse } : dataResponse;
41
+ }
42
+ };
43
+ let DatapassInterceptor = class DatapassInterceptor {
44
+ constructor(client) {
45
+ this.client = client;
46
+ }
47
+ onModuleInit() {
48
+ this.cacheService = this.client.getService('RequestService');
49
+ }
50
+ async intercept(context, next) {
51
+ const request = context.switchToHttp().getRequest();
52
+ const response = context.switchToHttp().getResponse();
53
+ const { method, url, query } = request;
54
+ const dataQuery = (0, class_transformer_1.plainToClass)(cache_dto_1.parametersClientCacheDTO, query);
55
+ const TTL = dataQuery.ttl;
56
+ const dataCache = (0, class_transformer_1.plainToClass)(cache_dto_1.parametersControllerCacheDTO, TTL
57
+ ? Object.assign(Object.assign({}, Reflect.getMetadata('data-cache', context.getHandler())), { ttl: TTL }) : Reflect.getMetadata('data-cache', context.getHandler()));
58
+ const KEY = dataCache.useKeyUrl ? `${method}-${url.split('?')[0]}` : dataCache.key;
59
+ const valid = await (0, class_validator_1.validate)(dataCache);
60
+ if (valid.length) {
61
+ const responseError = {
62
+ message: Object.values(valid[0].constraints),
63
+ error: 'BAD_REQUEST',
64
+ status: 400,
65
+ };
66
+ return parseErrorReturn(dataCache.responseHttp, response, responseError);
67
+ }
68
+ let getData;
69
+ try {
70
+ getData = !dataQuery.noCache
71
+ ? await this.cacheService.GetCache({ request: JSON.stringify({ key: KEY }) }).toPromise()
72
+ : null;
73
+ getData = !dataQuery.noCache ? JSON.parse(getData.response) : null;
74
+ }
75
+ catch (error) {
76
+ if (!dataCache.ignoreExceptions) {
77
+ const responseError = {
78
+ message: error.message ? error.message : error,
79
+ error: 'BAD_REQUEST',
80
+ status: 400,
81
+ };
82
+ return parseErrorReturn(dataCache.responseHttp, response, responseError);
83
+ }
84
+ }
85
+ if (getData && getData.foundCache) {
86
+ try {
87
+ return (0, rxjs_1.of)(dataCache.keyResponse
88
+ ? { [dataCache.keyResponse]: getData.response, cache: true }
89
+ : Object.assign(Object.assign({}, getData.response), { cache: true }));
90
+ }
91
+ catch (error) {
92
+ if (!dataCache.ignoreExceptions) {
93
+ const responseError = {
94
+ message: error.message ? error.message : error,
95
+ error: 'BAD_REQUEST',
96
+ status: 400,
97
+ };
98
+ return parseErrorReturn(dataCache.responseHttp, response, responseError);
99
+ }
100
+ }
101
+ }
102
+ else {
103
+ let checkError;
104
+ let responseSent;
105
+ return next.handle().pipe((0, operators_1.switchMap)(async (data) => {
106
+ const dataResponse = data;
107
+ try {
108
+ await this.cacheService
109
+ .SetCache({
110
+ request: JSON.stringify({
111
+ key: KEY,
112
+ value: data,
113
+ ttl: dataCache.ttl,
114
+ }),
115
+ })
116
+ .toPromise();
117
+ const resp = parseResponseReturn(dataCache.responseHttp, response, dataCache, dataResponse);
118
+ if (resp) {
119
+ return resp;
120
+ }
121
+ else {
122
+ responseSent = true;
123
+ }
124
+ }
125
+ catch (error) {
126
+ if (!dataCache.ignoreExceptions) {
127
+ checkError = error.message ? error.message : error;
128
+ throw checkError;
129
+ }
130
+ }
131
+ finally {
132
+ if (dataCache.ignoreExceptions && !responseSent) {
133
+ return parseResponseReturn(dataCache.responseHttp, response, dataCache, dataResponse);
134
+ }
135
+ else if (!checkError && !responseSent) {
136
+ return parseResponseReturn(dataCache.responseHttp, response, dataCache, dataResponse);
137
+ }
138
+ }
139
+ }), (0, operators_1.catchError)(() => {
140
+ if (!dataCache.ignoreExceptions) {
141
+ const responseError = {
142
+ message: checkError,
143
+ error: 'BAD_REQUEST',
144
+ status: 400,
145
+ };
146
+ return parseErrorReturn(dataCache.responseHttp, response, responseError);
147
+ }
148
+ }));
149
+ }
150
+ }
151
+ };
152
+ DatapassInterceptor = __decorate([
153
+ (0, common_1.Injectable)(),
154
+ __param(0, (0, decorators_1.Inject)('RQ_PACKAGE')),
155
+ __metadata("design:paramtypes", [Object])
156
+ ], DatapassInterceptor);
157
+ exports.DatapassInterceptor = DatapassInterceptor;
158
+ //# sourceMappingURL=datapass.interceptor.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CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;qBACvF;yBAAM,IAAI,CAAC,UAAU,IAAI,CAAC,YAAY,EAAE;wBACvC,OAAO,mBAAmB,CAAC,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;qBACvF;iBACF;YACH,CAAC,CAAC,EACF,IAAA,sBAAU,EAAC,GAAG,EAAE;gBACd,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;oBAC/B,MAAM,aAAa,GAAG;wBACpB,OAAO,EAAE,UAAU;wBACnB,KAAK,EAAE,aAAa;wBACpB,MAAM,EAAE,GAAG;qBACZ,CAAC;oBACF,OAAO,gBAAgB,CAAC,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;iBAC1E;YACH,CAAC,CAAC,CACH,CAAC;SACH;IACH,CAAC;CACF,CAAA;AAtHY,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAGE,WAAA,IAAA,mBAAM,EAAC,YAAY,CAAC,CAAA;;GAFtB,mBAAmB,CAsH/B;AAtHY,kDAAmB"}
@@ -0,0 +1,12 @@
1
+ export declare class parametersClientCacheDTO {
2
+ 'noCache': boolean;
3
+ 'ttl': number;
4
+ }
5
+ export declare class parametersControllerCacheDTO {
6
+ 'key': string;
7
+ 'ttl': number;
8
+ 'keyResponse': string;
9
+ 'useKeyUrl': boolean;
10
+ 'ignoreExceptions': boolean;
11
+ responseHttp: boolean;
12
+ }