@mondart/nestjs-common-module 2.5.0 → 2.6.0

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 (33) hide show
  1. package/dist/decorators/iam-context.decorator.d.ts +2 -0
  2. package/dist/decorators/iam-context.decorator.js +25 -15
  3. package/dist/dto/response/iam-context.dto.d.ts +4 -5
  4. package/dist/dto/response/iam-context.dto.js +10 -15
  5. package/dist/interfaces/get-agent.interface.d.ts +0 -1
  6. package/dist/lib/captcha/captcha.decorator.d.ts +4 -0
  7. package/dist/lib/captcha/captcha.decorator.js +7 -0
  8. package/dist/lib/captcha/captcha.exception.d.ts +4 -0
  9. package/dist/lib/captcha/captcha.exception.js +11 -0
  10. package/dist/lib/captcha/captcha.guard.d.ts +16 -0
  11. package/dist/lib/captcha/captcha.guard.js +83 -0
  12. package/dist/lib/captcha/captcha.interface.d.ts +26 -0
  13. package/dist/lib/captcha/captcha.interface.js +4 -0
  14. package/dist/lib/captcha/captcha.module.d.ts +8 -0
  15. package/dist/lib/captcha/captcha.module.js +97 -0
  16. package/dist/lib/captcha/enums/captcha-decorators.enum.d.ts +3 -0
  17. package/dist/lib/captcha/enums/captcha-decorators.enum.js +7 -0
  18. package/dist/lib/captcha/enums/captcha-messages.enum.d.ts +3 -0
  19. package/dist/lib/captcha/enums/captcha-messages.enum.js +7 -0
  20. package/dist/lib/captcha/index.d.ts +5 -0
  21. package/dist/lib/captcha/index.js +9 -0
  22. package/dist/lib/index.d.ts +2 -0
  23. package/dist/lib/index.js +2 -0
  24. package/dist/lib/request/enums/http-methods.enum.d.ts +7 -0
  25. package/dist/lib/request/enums/http-methods.enum.js +11 -0
  26. package/dist/lib/request/index.d.ts +4 -0
  27. package/dist/lib/request/index.js +9 -0
  28. package/dist/lib/request/request.module.d.ts +2 -0
  29. package/dist/lib/request/request.module.js +23 -0
  30. package/dist/lib/request/request.service.d.ts +31 -0
  31. package/dist/lib/request/request.service.js +75 -0
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +2 -2
@@ -0,0 +1,75 @@
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.HttpMethods = exports.RequestService = void 0;
13
+ const axios_1 = require("@nestjs/axios");
14
+ const common_1 = require("@nestjs/common");
15
+ const rxjs_1 = require("rxjs");
16
+ const http_methods_enum_1 = require("./enums/http-methods.enum");
17
+ Object.defineProperty(exports, "HttpMethods", { enumerable: true, get: function () { return http_methods_enum_1.HttpMethods; } });
18
+ const config_1 = require("@nestjs/config");
19
+ let RequestService = class RequestService {
20
+ constructor(configService, httpService) {
21
+ this.configService = configService;
22
+ this.httpService = httpService;
23
+ }
24
+ async sendRaw({ method, body, isAdditionalPath, path, headers, token, }) {
25
+ const url = isAdditionalPath
26
+ ? this.configService.get('app.baseUrl') + path
27
+ : path;
28
+ const result = await (0, rxjs_1.firstValueFrom)(this.httpService.request({
29
+ method,
30
+ data: body || {},
31
+ url: url,
32
+ headers: {
33
+ ...headers,
34
+ Authorization: `Bearer ${token}`,
35
+ },
36
+ }));
37
+ return result;
38
+ }
39
+ async send({ method, body, path, headers, token, params, }) {
40
+ try {
41
+ const url = params ? path + `?${params}` : path;
42
+ const result = await (0, rxjs_1.firstValueFrom)(this.httpService.request({
43
+ method,
44
+ url,
45
+ data: body || {},
46
+ headers: {
47
+ ...headers,
48
+ Authorization: token ? `Bearer ${token}` : undefined,
49
+ },
50
+ }));
51
+ return result?.data;
52
+ }
53
+ catch (err) {
54
+ return err;
55
+ }
56
+ }
57
+ post(payload) {
58
+ return this.send({ ...payload, method: http_methods_enum_1.HttpMethods.POST });
59
+ }
60
+ get(payload) {
61
+ return this.send({ ...payload, method: http_methods_enum_1.HttpMethods.GET });
62
+ }
63
+ patch(payload) {
64
+ return this.send({ ...payload, method: http_methods_enum_1.HttpMethods.PATCH });
65
+ }
66
+ remove(payload) {
67
+ return this.send({ ...payload, method: http_methods_enum_1.HttpMethods.DELETE });
68
+ }
69
+ };
70
+ exports.RequestService = RequestService;
71
+ exports.RequestService = RequestService = __decorate([
72
+ (0, common_1.Injectable)(),
73
+ __metadata("design:paramtypes", [config_1.ConfigService,
74
+ axios_1.HttpService])
75
+ ], RequestService);