itlab-internal-services 2.11.4 → 2.12.1

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 (155) hide show
  1. package/dist/axios.js +3 -4
  2. package/dist/controllers/index.d.ts +2 -0
  3. package/dist/{interceptors → controllers}/index.js +2 -1
  4. package/dist/{liveness.probe.d.ts → controllers/liveness.probe.d.ts} +1 -1
  5. package/dist/{liveness.probe.js → controllers/liveness.probe.js} +1 -1
  6. package/dist/create-duplicate-checker.function.d.ts +2 -27
  7. package/dist/create-duplicate-checker.function.js +3 -5
  8. package/dist/decorators/account.decorator.d.ts +21 -0
  9. package/dist/decorators/account.decorator.js +51 -0
  10. package/dist/decorators/index.d.ts +2 -0
  11. package/dist/{guards → decorators}/index.js +2 -2
  12. package/dist/decorators/jwt.decorator.d.ts +9 -0
  13. package/dist/decorators/jwt.decorator.js +18 -0
  14. package/dist/env.d.ts +2 -18
  15. package/dist/env.js +3 -19
  16. package/dist/exceptions/bad-body.exception.d.ts +12 -17
  17. package/dist/exceptions/bad-body.exception.js +15 -41
  18. package/dist/exceptions/bad-parameter.exception.d.ts +21 -0
  19. package/dist/exceptions/bad-parameter.exception.js +37 -0
  20. package/dist/exceptions/duplicate.exception.d.ts +11 -16
  21. package/dist/exceptions/duplicate.exception.js +14 -40
  22. package/dist/exceptions/index.d.ts +1 -23
  23. package/dist/exceptions/index.js +1 -20
  24. package/dist/factories/merge.factory.d.ts +0 -25
  25. package/dist/factories/virtuals.factory.d.ts +16 -29
  26. package/dist/factories/virtuals.factory.js +12 -0
  27. package/dist/http.logger.js +1 -2
  28. package/dist/increment-views.d.ts +0 -25
  29. package/dist/increment-views.js +6 -7
  30. package/dist/increment.function.d.ts +0 -25
  31. package/dist/increment.function.js +1 -2
  32. package/dist/index.d.ts +2 -4
  33. package/dist/index.js +2 -4
  34. package/dist/models/content.d.ts +1 -1
  35. package/dist/models/content.js +1 -2
  36. package/dist/models/filter/limit.property.d.ts +1 -1
  37. package/dist/models/filter/limit.property.js +1 -2
  38. package/dist/models/filter/skip.property.d.ts +1 -1
  39. package/dist/models/filter/skip.property.js +1 -2
  40. package/dist/models/filter/sort-direction.property.d.ts +1 -1
  41. package/dist/models/filter/sort-direction.property.js +1 -2
  42. package/dist/models/filter/sort-field.property.d.ts +1 -1
  43. package/dist/models/filter/sort-field.property.js +1 -2
  44. package/dist/models/search-result.d.ts +1 -1
  45. package/dist/models/search-result.js +2 -2
  46. package/dist/models/thumbnail/alt.property.d.ts +1 -1
  47. package/dist/models/thumbnail/alt.property.js +1 -2
  48. package/dist/models/thumbnail/background.property.d.ts +1 -1
  49. package/dist/models/thumbnail/background.property.js +1 -2
  50. package/dist/models/thumbnail/contain.property.d.ts +1 -1
  51. package/dist/models/thumbnail/contain.property.js +1 -2
  52. package/dist/models/thumbnail/index.d.ts +1 -1
  53. package/dist/models/thumbnail/index.js +2 -2
  54. package/dist/models/thumbnail/max-height.property.d.ts +1 -1
  55. package/dist/models/thumbnail/max-height.property.js +1 -2
  56. package/dist/models/thumbnail/max-width.property.d.ts +1 -1
  57. package/dist/models/thumbnail/max-width.property.js +1 -2
  58. package/dist/models/thumbnail/src.property.d.ts +1 -1
  59. package/dist/models/thumbnail/src.property.js +1 -2
  60. package/dist/modules/authentication/auth.guard.d.ts +21 -0
  61. package/dist/modules/authentication/auth.guard.js +72 -0
  62. package/dist/modules/authentication/authentication.module.js +4 -3
  63. package/dist/modules/authentication/index.d.ts +4 -2
  64. package/dist/modules/authentication/index.js +4 -2
  65. package/dist/modules/authentication/internal.guard.d.ts +26 -0
  66. package/dist/modules/authentication/internal.guard.js +56 -0
  67. package/dist/modules/authentication/perms.guard.d.ts +30 -0
  68. package/dist/modules/authentication/perms.guard.js +63 -0
  69. package/dist/modules/authentication/public.guard.d.ts +7 -0
  70. package/dist/modules/authentication/public.guard.js +17 -0
  71. package/dist/modules/comment/comment.controller.js +6 -5
  72. package/dist/modules/comment/comment.module-options.js +3 -3
  73. package/dist/modules/comment/comment.module.js +8 -8
  74. package/dist/modules/comment/comment.service.d.ts +0 -25
  75. package/dist/modules/comment/comment.service.js +2 -3
  76. package/dist/modules/database/database.module.js +25 -39
  77. package/dist/modules/database/model-service/dbs/hub-account.db.d.ts +0 -25
  78. package/dist/modules/database/model-service/dbs/hub-books.db.d.ts +0 -25
  79. package/dist/modules/database/model-service/dbs/hub-comments.db.d.ts +0 -25
  80. package/dist/modules/database/model-service/dbs/hub-content.db.d.ts +0 -25
  81. package/dist/modules/database/model-service/dbs/hub-demo-hive.db.d.ts +0 -25
  82. package/dist/modules/database/model-service/dbs/hub-events.db.d.ts +0 -25
  83. package/dist/modules/database/model-service/dbs/hub-hackschool.db.d.ts +0 -25
  84. package/dist/modules/database/model-service/dbs/hub-newsroom.db.d.ts +0 -25
  85. package/dist/modules/database/model-service/dbs/hub-podcasts.db.d.ts +0 -25
  86. package/dist/modules/database/model-service/dbs/hub-team.db.d.ts +0 -25
  87. package/dist/modules/database/model-service/dbs/hub-tech-radar.db.d.ts +0 -25
  88. package/dist/modules/database/model-service/model.service.d.ts +3031 -6094
  89. package/dist/modules/database/populate-service/populate.service.d.ts +0 -25
  90. package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +0 -25
  91. package/dist/modules/fetch/fetch.service.d.ts +3 -2
  92. package/dist/modules/fetch/fetch.service.js +14 -0
  93. package/dist/modules/like/like.controller.js +11 -10
  94. package/dist/modules/like/like.module-options.js +5 -6
  95. package/dist/modules/like/like.module.js +4 -4
  96. package/dist/modules/like/like.service.d.ts +0 -25
  97. package/dist/pipes/hub-id.pipe.d.ts +29 -0
  98. package/dist/pipes/hub-id.pipe.js +76 -0
  99. package/dist/pipes/hub-resource.pipe.d.ts +8 -20
  100. package/dist/pipes/hub-resource.pipe.js +25 -45
  101. package/dist/pipes/index.d.ts +2 -2
  102. package/dist/pipes/index.js +2 -2
  103. package/dist/pipes/mongo-id.pipe.d.ts +14 -0
  104. package/dist/pipes/mongo-id.pipe.js +49 -0
  105. package/dist/schema.transformer.d.ts +0 -25
  106. package/dist/schema.transformer.js +1 -2
  107. package/dist/swagger.config.js +6 -6
  108. package/dist/transform/_trim.js +1 -2
  109. package/dist/transform/castToArray.js +1 -2
  110. package/dist/transform/transformBoolean.js +1 -2
  111. package/dist/transform/transformImage.js +1 -2
  112. package/dist/transform/transformNumber.js +1 -2
  113. package/dist/transform/transformString.js +1 -2
  114. package/dist/transform/transformStringArray.js +1 -2
  115. package/dist/transform/transformStringLike.js +3 -4
  116. package/dist/transform/transformStringLowerCase.js +1 -2
  117. package/dist/transform/transformStringSet.js +1 -2
  118. package/dist/transform/transformTimestamp.js +1 -2
  119. package/package.json +18 -22
  120. package/dist/exceptions/not-found.exception.d.ts +0 -26
  121. package/dist/exceptions/not-found.exception.js +0 -57
  122. package/dist/guards/index.d.ts +0 -2
  123. package/dist/guards/perms.guard.d.ts +0 -39
  124. package/dist/guards/perms.guard.js +0 -92
  125. package/dist/guards/puplic.guard.d.ts +0 -7
  126. package/dist/guards/puplic.guard.js +0 -15
  127. package/dist/interceptors/errors.interceptor.d.ts +0 -43
  128. package/dist/interceptors/errors.interceptor.js +0 -109
  129. package/dist/interceptors/index.d.ts +0 -1
  130. package/dist/modules/authentication/internal/index.d.ts +0 -3
  131. package/dist/modules/authentication/internal/index.js +0 -19
  132. package/dist/modules/authentication/internal/internal.constants.d.ts +0 -9
  133. package/dist/modules/authentication/internal/internal.constants.js +0 -12
  134. package/dist/modules/authentication/internal/internal.decorators.d.ts +0 -5
  135. package/dist/modules/authentication/internal/internal.decorators.js +0 -15
  136. package/dist/modules/authentication/internal/internal.guard.d.ts +0 -9
  137. package/dist/modules/authentication/internal/internal.guard.js +0 -23
  138. package/dist/modules/authentication/internal/internal.strategy.d.ts +0 -27
  139. package/dist/modules/authentication/internal/internal.strategy.js +0 -53
  140. package/dist/modules/authentication/jwt/index.d.ts +0 -4
  141. package/dist/modules/authentication/jwt/index.js +0 -22
  142. package/dist/modules/authentication/jwt/jwt.constants.d.ts +0 -28
  143. package/dist/modules/authentication/jwt/jwt.constants.js +0 -22
  144. package/dist/modules/authentication/jwt/jwt.decorators.d.ts +0 -17
  145. package/dist/modules/authentication/jwt/jwt.decorators.js +0 -32
  146. package/dist/modules/authentication/jwt/jwt.guard.d.ts +0 -24
  147. package/dist/modules/authentication/jwt/jwt.guard.js +0 -54
  148. package/dist/modules/authentication/jwt/jwt.strategy.d.ts +0 -24
  149. package/dist/modules/authentication/jwt/jwt.strategy.js +0 -50
  150. package/dist/pipes/hid.pipe.d.ts +0 -39
  151. package/dist/pipes/hid.pipe.js +0 -92
  152. package/dist/pipes/id.pipe.d.ts +0 -26
  153. package/dist/pipes/id.pipe.js +0 -67
  154. /package/dist/{favicon.controller.d.ts → controllers/favicon.controller.d.ts} +0 -0
  155. /package/dist/{favicon.controller.js → controllers/favicon.controller.js} +0 -0
package/dist/axios.js CHANGED
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createAxios = void 0;
6
+ exports.createAxios = createAxios;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const internal_constants_1 = require("./modules/authentication/internal/internal.constants");
8
+ const modules_1 = require("./modules");
9
9
  /**
10
10
  * Create an axios instance
11
11
  * @param options - the options for the axios instance
@@ -14,7 +14,6 @@ const internal_constants_1 = require("./modules/authentication/internal/internal
14
14
  function createAxios(options) {
15
15
  return axios_1.default.create({
16
16
  baseURL: options.baseUrl,
17
- headers: { [internal_constants_1.INTERNAL_HEADER_KEY]: options.k8sToken },
17
+ headers: { [modules_1.INTERNAL_HEADER_KEY]: options.k8sToken },
18
18
  });
19
19
  }
20
- exports.createAxios = createAxios;
@@ -0,0 +1,2 @@
1
+ export * from './favicon.controller';
2
+ export * from './liveness.probe';
@@ -14,4 +14,5 @@ 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("./errors.interceptor"), exports);
17
+ __exportStar(require("./favicon.controller"), exports);
18
+ __exportStar(require("./liveness.probe"), exports);
@@ -8,7 +8,7 @@ export declare class LivenessProbe {
8
8
  /**
9
9
  * A function that handles getting alive status.
10
10
  *
11
- * @param {@Res()} response - the response object
11
+ * @param {Response} response - the response object
12
12
  * @return {Promise<void>} a Promise that resolves to void
13
13
  */
14
14
  getAlive(response: Response): Promise<void>;
@@ -33,7 +33,7 @@ let LivenessProbe = class LivenessProbe {
33
33
  /**
34
34
  * A function that handles getting alive status.
35
35
  *
36
- * @param {@Res()} response - the response object
36
+ * @param {Response} response - the response object
37
37
  * @return {Promise<void>} a Promise that resolves to void
38
38
  */
39
39
  getAlive(response) {
@@ -1,28 +1,3 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose/types/inferschematype" />
25
- /// <reference types="mongoose/types/inferrawdoctype" />
1
+ import { HttpException } from '@nestjs/common';
26
2
  import { Document, Model } from 'mongoose';
27
- import { ErrorException } from './exceptions';
28
- export declare function createDuplicateChecker<TDto extends Partial<TDocument>, TDocument extends Document>(model: Model<TDocument>, criticalKeys: (keyof TDto & keyof TDocument)[], error?: new () => ErrorException): (dto: TDto, resource?: TDocument) => Promise<void>;
3
+ export declare function createDuplicateChecker<TDto extends Partial<TDocument>, TDocument extends Document>(model: Model<TDocument>, criticalKeys: (keyof TDto & keyof TDocument)[], Error: new () => HttpException): (dto: TDto, resource?: TDocument) => Promise<void>;
@@ -9,9 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createDuplicateChecker = void 0;
13
- const exceptions_1 = require("./exceptions");
14
- function createDuplicateChecker(model, criticalKeys, error = exceptions_1.DuplicateException) {
12
+ exports.createDuplicateChecker = createDuplicateChecker;
13
+ function createDuplicateChecker(model, criticalKeys, Error) {
15
14
  return (dto, resource) => __awaiter(this, void 0, void 0, function* () {
16
15
  const fq = {};
17
16
  for (const key of criticalKeys) {
@@ -23,7 +22,6 @@ function createDuplicateChecker(model, criticalKeys, error = exceptions_1.Duplic
23
22
  const found = yield model.findOne(fq);
24
23
  const compareId = resource ? String(resource._id).toLowerCase() : undefined;
25
24
  if (found && String(found._id).toLowerCase() !== compareId)
26
- throw new error();
25
+ throw new Error();
27
26
  });
28
27
  }
29
- exports.createDuplicateChecker = createDuplicateChecker;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Decorator to extract account information from the request.
3
+ * @param {keyof AccountEntity} attribute - Optional: Attribute of the account to extract.
4
+ * @returns {any} The extracted account or attribute of the account.
5
+ */
6
+ export declare const Account: (...dataOrPipes: (keyof AccountEntity | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
7
+ /**
8
+ * Represents an account entity with user details and permissions.
9
+ */
10
+ export declare class AccountEntity {
11
+ /** Unique identifier for the account */
12
+ id: string;
13
+ /** Array of permissions for the account */
14
+ perms: string[];
15
+ /** Username of the account */
16
+ username: string;
17
+ /** Email of the account */
18
+ email: string;
19
+ /** Optional: Avatar of the account */
20
+ avatar?: string;
21
+ }
@@ -0,0 +1,51 @@
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.AccountEntity = exports.Account = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const swagger_1 = require("@nestjs/swagger");
15
+ /**
16
+ * Decorator to extract account information from the request.
17
+ * @param {keyof AccountEntity} attribute - Optional: Attribute of the account to extract.
18
+ * @returns {any} The extracted account or attribute of the account.
19
+ */
20
+ exports.Account = (0, common_1.createParamDecorator)((attribute, context) => {
21
+ const account = context.switchToHttp().getRequest().user;
22
+ if (!account)
23
+ throw new common_1.UnprocessableEntityException('User is missing');
24
+ return attribute ? account[attribute] : account;
25
+ });
26
+ /**
27
+ * Represents an account entity with user details and permissions.
28
+ */
29
+ class AccountEntity {
30
+ }
31
+ exports.AccountEntity = AccountEntity;
32
+ __decorate([
33
+ (0, swagger_1.ApiProperty)({ description: 'Unique identifier for the account', example: '000000000000000000000000' }),
34
+ __metadata("design:type", String)
35
+ ], AccountEntity.prototype, "id", void 0);
36
+ __decorate([
37
+ (0, swagger_1.ApiProperty)({ description: 'Array of permissions for the account', example: ['news.publish'] }),
38
+ __metadata("design:type", Array)
39
+ ], AccountEntity.prototype, "perms", void 0);
40
+ __decorate([
41
+ (0, swagger_1.ApiProperty)({ description: 'Username of the account', example: 'Timo S.' }),
42
+ __metadata("design:type", String)
43
+ ], AccountEntity.prototype, "username", void 0);
44
+ __decorate([
45
+ (0, swagger_1.ApiProperty)({ description: 'Email of the account', example: 'timo@example.com' }),
46
+ __metadata("design:type", String)
47
+ ], AccountEntity.prototype, "email", void 0);
48
+ __decorate([
49
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Avatar of the account', example: 'https://example.com/avatar.jpg' }),
50
+ __metadata("design:type", String)
51
+ ], AccountEntity.prototype, "avatar", void 0);
@@ -0,0 +1,2 @@
1
+ export * from './account.decorator';
2
+ export * from './jwt.decorator';
@@ -14,5 +14,5 @@ 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("./perms.guard"), exports);
18
- __exportStar(require("./puplic.guard"), exports);
17
+ __exportStar(require("./account.decorator"), exports);
18
+ __exportStar(require("./jwt.decorator"), exports);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Decorator to extract the JWT token from the request header.
3
+ *
4
+ * This decorator uses the 'Authorization' header to retrieve the JWT token.
5
+ * It assumes the token follows the 'Bearer <token>' format and removes the 'Bearer ' prefix.
6
+ *
7
+ * @returns {string} The extracted JWT token.
8
+ */
9
+ export declare const Jwt: (...dataOrPipes: any[]) => ParameterDecorator;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Jwt = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * Decorator to extract the JWT token from the request header.
7
+ *
8
+ * This decorator uses the 'Authorization' header to retrieve the JWT token.
9
+ * It assumes the token follows the 'Bearer <token>' format and removes the 'Bearer ' prefix.
10
+ *
11
+ * @returns {string} The extracted JWT token.
12
+ */
13
+ exports.Jwt = (0, common_1.createParamDecorator)((_, context) => {
14
+ const authorizationHeader = context.switchToHttp().getRequest().header('Authorization');
15
+ if (!authorizationHeader)
16
+ throw new common_1.UnprocessableEntityException('Authorization header is missing');
17
+ return authorizationHeader.replace('Bearer ', '');
18
+ });
package/dist/env.d.ts CHANGED
@@ -1,23 +1,7 @@
1
- /**
2
- * Environment variables
3
- *
4
- * @exports
5
- * ENV_K8S_TOKEN
6
- * ENV_JWT_SECRET
7
- * ENV_MONGO_SRV
8
- * ENV_MONGO_USERNAME
9
- * ENV_MONGO_PASSWORD
10
- * ENV_MONGO_CERT_DIR
11
- * ENV_MONGO_TLS_CA_CRT
12
- * ENV_MONGO_TLS_TLS_CRT
13
- * ENV_MONGO_TLS_TLS_KEY
14
- */
15
1
  export declare const ENV_K8S_TOKEN = "K8S_TOKEN";
16
2
  export declare const ENV_JWT_SECRET = "JWT_SECRET";
17
3
  export declare const ENV_MONGO_SRV = "MONGO_SRV";
18
4
  export declare const ENV_MONGO_USERNAME = "MONGO_USERNAME";
19
5
  export declare const ENV_MONGO_PASSWORD = "MONGO_PASSWORD";
20
- export declare const ENV_MONGO_CERT_DIR = "MONGO_CERT_DIR";
21
- export declare const ENV_MONGO_TLS_CA_CRT = "MONGO_TLS_CA_CRT";
22
- export declare const ENV_MONGO_TLS_TLS_CRT = "MONGO_TLS_TLS_CRT";
23
- export declare const ENV_MONGO_TLS_TLS_KEY = "MONGO_TLS_TLS_KEY";
6
+ export declare const ENV_MONGO_TLS_CA_FILE = "MONGO_TLS_CA_FILE";
7
+ export declare const ENV_MONGO_TLS_CERT_KEY_FILE = "MONGO_TLS_CERT_KEY_FILE";
package/dist/env.js CHANGED
@@ -1,26 +1,10 @@
1
1
  "use strict";
2
- /**
3
- * Environment variables
4
- *
5
- * @exports
6
- * ENV_K8S_TOKEN
7
- * ENV_JWT_SECRET
8
- * ENV_MONGO_SRV
9
- * ENV_MONGO_USERNAME
10
- * ENV_MONGO_PASSWORD
11
- * ENV_MONGO_CERT_DIR
12
- * ENV_MONGO_TLS_CA_CRT
13
- * ENV_MONGO_TLS_TLS_CRT
14
- * ENV_MONGO_TLS_TLS_KEY
15
- */
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ENV_MONGO_TLS_TLS_KEY = exports.ENV_MONGO_TLS_TLS_CRT = exports.ENV_MONGO_TLS_CA_CRT = exports.ENV_MONGO_CERT_DIR = exports.ENV_MONGO_PASSWORD = exports.ENV_MONGO_USERNAME = exports.ENV_MONGO_SRV = exports.ENV_JWT_SECRET = exports.ENV_K8S_TOKEN = void 0;
3
+ exports.ENV_MONGO_TLS_CERT_KEY_FILE = exports.ENV_MONGO_TLS_CA_FILE = exports.ENV_MONGO_PASSWORD = exports.ENV_MONGO_USERNAME = exports.ENV_MONGO_SRV = exports.ENV_JWT_SECRET = exports.ENV_K8S_TOKEN = void 0;
18
4
  exports.ENV_K8S_TOKEN = 'K8S_TOKEN';
19
5
  exports.ENV_JWT_SECRET = 'JWT_SECRET';
20
6
  exports.ENV_MONGO_SRV = 'MONGO_SRV';
21
7
  exports.ENV_MONGO_USERNAME = 'MONGO_USERNAME';
22
8
  exports.ENV_MONGO_PASSWORD = 'MONGO_PASSWORD';
23
- exports.ENV_MONGO_CERT_DIR = 'MONGO_CERT_DIR';
24
- exports.ENV_MONGO_TLS_CA_CRT = 'MONGO_TLS_CA_CRT';
25
- exports.ENV_MONGO_TLS_TLS_CRT = 'MONGO_TLS_TLS_CRT';
26
- exports.ENV_MONGO_TLS_TLS_KEY = 'MONGO_TLS_TLS_KEY';
9
+ exports.ENV_MONGO_TLS_CA_FILE = 'MONGO_TLS_CA_FILE';
10
+ exports.ENV_MONGO_TLS_CERT_KEY_FILE = 'MONGO_TLS_CERT_KEY_FILE';
@@ -1,26 +1,21 @@
1
- import { ErrorException, UseException } from '.';
1
+ import { UnprocessableEntityException } from '@nestjs/common';
2
2
  /**
3
- * Custom exception for bad request body
3
+ * Represents a bad body exception.
4
4
  * @class BadBodyException
5
- * @extends {ErrorException}
5
+ * @extends {UnprocessableEntityException}
6
6
  */
7
- export declare class BadBodyException extends ErrorException {
7
+ export declare class BadBodyException extends UnprocessableEntityException {
8
8
  /**
9
- * Constructor for BadBodyException
10
- * @param description - optional description for the exception
9
+ * Constructor for BadBodyException.
10
+ * @param message - The message for the exception.
11
+ * @description Creates a new BadBodyException with the given body.
11
12
  */
12
- constructor(description?: string);
13
+ constructor(message?: string);
13
14
  }
14
15
  /**
15
- * Creates an ApiBadBody decorator with the given description
16
- * @param description - optional description for the exception
17
- * @returns A decorator that creates an API bad body
18
- */
19
- export declare const ApiBadBody: (description?: string) => MethodDecorator & ClassDecorator;
20
- /**
21
- * Creates a bad body exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
16
+ * Creates an ApiBadBodyResponse decorator with the given description.
22
17
  *
23
- * @param {string} description - The description for the bad body exception
24
- * @return {UseException<typeof BadBodyException>} An array containing the Exception class and the ApiDecorator function
18
+ * @param {string} description - The description for the exception.
19
+ * @returns A decorator that creates an API bad body response.
25
20
  */
26
- export declare function useBadBodyException(description?: string): UseException<typeof BadBodyException>;
21
+ export declare function ApiBadBodyResponse(description?: string): MethodDecorator;
@@ -1,57 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBadBodyException = exports.ApiBadBody = exports.BadBodyException = void 0;
3
+ exports.BadBodyException = void 0;
4
+ exports.ApiBadBodyResponse = ApiBadBodyResponse;
4
5
  const common_1 = require("@nestjs/common");
5
6
  const swagger_1 = require("@nestjs/swagger");
6
- const _1 = require(".");
7
- /** Status code for bad bodies */
8
- const status = common_1.HttpStatus.METHOD_NOT_ALLOWED;
9
- /** Description for bad bodies */
10
- const error = 'Bad Body';
11
7
  /**
12
- * Custom exception for bad request body
8
+ * Represents a bad body exception.
13
9
  * @class BadBodyException
14
- * @extends {ErrorException}
10
+ * @extends {UnprocessableEntityException}
15
11
  */
16
- class BadBodyException extends _1.ErrorException {
12
+ class BadBodyException extends common_1.UnprocessableEntityException {
17
13
  /**
18
- * Constructor for BadBodyException
19
- * @param description - optional description for the exception
14
+ * Constructor for BadBodyException.
15
+ * @param message - The message for the exception.
16
+ * @description Creates a new BadBodyException with the given body.
20
17
  */
21
- constructor(description) {
22
- super(error, status, description);
18
+ constructor(message) {
19
+ super(message || 'Invalid body');
23
20
  }
24
21
  }
25
22
  exports.BadBodyException = BadBodyException;
26
23
  /**
27
- * Creates an ApiBadBody decorator with the given description
28
- * @param description - optional description for the exception
29
- * @returns A decorator that creates an API bad body
30
- */
31
- const ApiBadBody = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
32
- exports.ApiBadBody = ApiBadBody;
33
- /**
34
- * Creates a bad body exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
24
+ * Creates an ApiBadBodyResponse decorator with the given description.
35
25
  *
36
- * @param {string} description - The description for the bad body exception
37
- * @return {UseException<typeof BadBodyException>} An array containing the Exception class and the ApiDecorator function
26
+ * @param {string} description - The description for the exception.
27
+ * @returns A decorator that creates an API bad body response.
38
28
  */
39
- function useBadBodyException(description = error) {
40
- /**
41
- * Creates a bad body exception with the given description
42
- * @class Exception
43
- * @extends {BadBodyException}
44
- */
45
- class Exception extends BadBodyException {
46
- /**
47
- * Constructor for BadBodyException.
48
- * @param desc - Description of the error.
49
- */
50
- constructor(desc = description) {
51
- super(desc);
52
- }
53
- }
54
- // Return an array containing the Exception class and the ApiDecorator function
55
- return [Exception, () => (0, exports.ApiBadBody)(description)];
29
+ function ApiBadBodyResponse(description) {
30
+ return (0, swagger_1.ApiUnprocessableEntityResponse)({ description: description || 'Invalid body' });
56
31
  }
57
- exports.useBadBodyException = useBadBodyException;
@@ -0,0 +1,21 @@
1
+ import { BadRequestException } from '@nestjs/common';
2
+ /**
3
+ * Represents a bad parameter exception.
4
+ * @class BadParameterException
5
+ * @extends {BadRequestException}
6
+ */
7
+ export declare class BadParameterException extends BadRequestException {
8
+ /**
9
+ * Constructor for BadParameterException.
10
+ * @param parameter - The invalid parameter.
11
+ * @description Creates a new BadParameterException with the given parameter.
12
+ */
13
+ constructor(parameter?: string);
14
+ }
15
+ /**
16
+ * Creates an ApiBadParameterResponse decorator with the given description.
17
+ *
18
+ * @param {...string} params - The invalid parameters.
19
+ * @returns A decorator that creates an API bad parameter response.
20
+ */
21
+ export declare function ApiBadParameterResponse(...params: string[]): MethodDecorator;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BadParameterException = void 0;
4
+ exports.ApiBadParameterResponse = ApiBadParameterResponse;
5
+ const common_1 = require("@nestjs/common");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ const itlab_functions_1 = require("itlab-functions");
8
+ /**
9
+ * Represents a bad parameter exception.
10
+ * @class BadParameterException
11
+ * @extends {BadRequestException}
12
+ */
13
+ class BadParameterException extends common_1.BadRequestException {
14
+ /**
15
+ * Constructor for BadParameterException.
16
+ * @param parameter - The invalid parameter.
17
+ * @description Creates a new BadParameterException with the given parameter.
18
+ */
19
+ constructor(parameter) {
20
+ super(`Invalid parameter${parameter ? `: ${parameter}` : ''}`);
21
+ }
22
+ }
23
+ exports.BadParameterException = BadParameterException;
24
+ /**
25
+ * Creates an ApiBadParameterResponse decorator with the given description.
26
+ *
27
+ * @param {...string} params - The invalid parameters.
28
+ * @returns A decorator that creates an API bad parameter response.
29
+ */
30
+ function ApiBadParameterResponse(...params) {
31
+ let description = 'Invalid parameter';
32
+ if (params.length > 0) {
33
+ description += params.length > 1 ? 's' : '';
34
+ description += `: ${(0, itlab_functions_1.toList)(params)}`;
35
+ }
36
+ return (0, swagger_1.ApiBadRequestResponse)({ description });
37
+ }
@@ -1,26 +1,21 @@
1
- import { ErrorException, UseException } from '.';
1
+ import { ConflictException } from '@nestjs/common';
2
2
  /**
3
- * Represents an exception for duplicate errors.
3
+ * Represents a duplicate exception.
4
4
  * @class DuplicateException
5
- * @extends {ErrorException}
5
+ * @extends {ConflictException}
6
6
  */
7
- export declare class DuplicateException extends ErrorException {
7
+ export declare class DuplicateException extends ConflictException {
8
8
  /**
9
9
  * Constructor for DuplicateException.
10
- * @param description - Optional description for the exception.
10
+ * @param message - The message for the exception.
11
+ * @description Creates a new DuplicateException with the given body.
11
12
  */
12
- constructor(description?: string);
13
+ constructor(message?: string);
13
14
  }
14
15
  /**
15
- * Creates an ApiDuplicate decorator with the given description
16
- * @param description - optional description for the exception
17
- * @returns A decorator that creates an API duplicate
18
- */
19
- export declare const ApiDuplicate: (description?: string) => MethodDecorator & ClassDecorator;
20
- /**
21
- * Creates a duplicate exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
16
+ * Creates an ApiDuplicateResponse decorator with the given description.
22
17
  *
23
- * @param {string} description - The description for the duplicate exception
24
- * @return {UseException<typeof DuplicateException>} An array containing the Exception class and the ApiDecorator function
18
+ * @param {string} description - The description for the exception.
19
+ * @returns A decorator that creates an API duplicate response.
25
20
  */
26
- export declare function useDuplicateException(description?: string): UseException<typeof DuplicateException>;
21
+ export declare function ApiDuplicateResponse(description?: string): MethodDecorator;
@@ -1,57 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDuplicateException = exports.ApiDuplicate = exports.DuplicateException = void 0;
3
+ exports.DuplicateException = void 0;
4
+ exports.ApiDuplicateResponse = ApiDuplicateResponse;
4
5
  const common_1 = require("@nestjs/common");
5
6
  const swagger_1 = require("@nestjs/swagger");
6
- const _1 = require(".");
7
- /** Status code for duplicates */
8
- const status = common_1.HttpStatus.CONFLICT;
9
- /** Description for duplicates */
10
- const error = 'Duplicate';
11
7
  /**
12
- * Represents an exception for duplicate errors.
8
+ * Represents a duplicate exception.
13
9
  * @class DuplicateException
14
- * @extends {ErrorException}
10
+ * @extends {ConflictException}
15
11
  */
16
- class DuplicateException extends _1.ErrorException {
12
+ class DuplicateException extends common_1.ConflictException {
17
13
  /**
18
14
  * Constructor for DuplicateException.
19
- * @param description - Optional description for the exception.
15
+ * @param message - The message for the exception.
16
+ * @description Creates a new DuplicateException with the given body.
20
17
  */
21
- constructor(description) {
22
- super(error, status, description);
18
+ constructor(message) {
19
+ super(message || 'This entity already exists');
23
20
  }
24
21
  }
25
22
  exports.DuplicateException = DuplicateException;
26
23
  /**
27
- * Creates an ApiDuplicate decorator with the given description
28
- * @param description - optional description for the exception
29
- * @returns A decorator that creates an API duplicate
30
- */
31
- const ApiDuplicate = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
32
- exports.ApiDuplicate = ApiDuplicate;
33
- /**
34
- * Creates a duplicate exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
24
+ * Creates an ApiDuplicateResponse decorator with the given description.
35
25
  *
36
- * @param {string} description - The description for the duplicate exception
37
- * @return {UseException<typeof DuplicateException>} An array containing the Exception class and the ApiDecorator function
26
+ * @param {string} description - The description for the exception.
27
+ * @returns A decorator that creates an API duplicate response.
38
28
  */
39
- function useDuplicateException(description = error) {
40
- /**
41
- * Creates a duplicate exception with the given description
42
- * @class Exception
43
- * @extends {DuplicateException}
44
- */
45
- class Exception extends DuplicateException {
46
- /**
47
- * Constructor for DuplicateException.
48
- * @param desc - Description of the error.
49
- */
50
- constructor(desc = description) {
51
- super(desc);
52
- }
53
- }
54
- // Return an array containing the Exception class and the ApiDecorator function
55
- return [Exception, () => (0, exports.ApiDuplicate)(description)];
29
+ function ApiDuplicateResponse(description) {
30
+ return (0, swagger_1.ApiConflictResponse)({ description: description || 'This entity already exists' });
56
31
  }
57
- exports.useDuplicateException = useDuplicateException;
@@ -1,25 +1,3 @@
1
- import { HttpException } from '@nestjs/common';
2
- /**
3
- * Custom error exception class
4
- * @class ErrorException
5
- * @extends {HttpException}
6
- */
7
- export declare class ErrorException extends HttpException {
8
- /**
9
- * Constructor for ErrorException
10
- * @param error - The error message
11
- * @param status - The status code
12
- * @param description - The description of the error
13
- */
14
- constructor(error: string, status: number, description?: string);
15
- }
16
- /**
17
- * Type representing the use of an exception
18
- * @typedef {Array} UseException
19
- * @property {typeof ErrorException} 0 - The type of error exception
20
- * @property {Function} 1 - The method and class decorator
21
- */
22
- export type UseException<T> = [T, () => MethodDecorator & ClassDecorator];
23
1
  export * from './bad-body.exception';
2
+ export * from './bad-parameter.exception';
24
3
  export * from './duplicate.exception';
25
- export * from './not-found.exception';
@@ -14,25 +14,6 @@ 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
- exports.ErrorException = void 0;
18
- const common_1 = require("@nestjs/common");
19
- /**
20
- * Custom error exception class
21
- * @class ErrorException
22
- * @extends {HttpException}
23
- */
24
- class ErrorException extends common_1.HttpException {
25
- /**
26
- * Constructor for ErrorException
27
- * @param error - The error message
28
- * @param status - The status code
29
- * @param description - The description of the error
30
- */
31
- constructor(error, status, description) {
32
- super({ message: [description || error], status, error }, status);
33
- }
34
- }
35
- exports.ErrorException = ErrorException;
36
17
  __exportStar(require("./bad-body.exception"), exports);
18
+ __exportStar(require("./bad-parameter.exception"), exports);
37
19
  __exportStar(require("./duplicate.exception"), exports);
38
- __exportStar(require("./not-found.exception"), exports);