From 760207fd4a76c197a268a46edaf85dd40008e0ad Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Tue, 15 Aug 2023 11:10:54 +0545 Subject: [PATCH] fix: pkg update --- .eslintrc.cjs | 3 +- package.json | 2 +- pnpm-lock.yaml | 80 ++++++++++++++----- src/_mocks_/index.ts | 1 + src/common/constant/string.constants.ts | 8 +- .../validation/is-after.validator.ts | 2 +- .../validation/is-enum-field.decorator.ts | 2 +- .../validation/validation-field.generator.ts | 7 +- src/common/guards/auth.guard.ts | 2 +- src/common/helpers/app.utils.ts | 11 ++- .../request-sanitizer.interceptor.ts | 6 +- src/lib/crud/crud.service.ts | 8 +- src/lib/firebase-admin/firebase.service.ts | 2 +- 13 files changed, 91 insertions(+), 43 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ee66c527..ba82839a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -6,7 +6,7 @@ module.exports = defineConfig({ parserOptions: { project: 'tsconfig.json', }, - ignorePatterns: ['migrations', 'src/generated'], + ignorePatterns: ['migrations', 'src/generated', '**/*.spec.ts', '**/*.e2e.ts'], // optimize this extends: ['@rubiin/eslint-config-typescript'], root: true, settings: { @@ -19,6 +19,7 @@ module.exports = defineConfig({ }, rules: { 'unicorn/prefer-module': 'off', + '@typescript-eslint/no-floating-promises': 'off', 'no-useless-constructor': 'off', // optimize this '@typescript-eslint/require-await': 'off', // optimize this '@typescript-eslint/no-unsafe-assignment': 'off', // optimize this diff --git a/package.json b/package.json index a13ab105..666b86e0 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,6 @@ "isomorphic-dompurify": "^1.8.0", "joi": "^17.9.2", "jspdf": "^2.5.1", - "load-pkg": "^4.0.0", "nestjs-cloudinary": "^2.0.6", "nestjs-fastjwt": "^0.0.1", "nestjs-i18n": "^10.2.6", @@ -124,6 +123,7 @@ "prom-client": "^14.2.0", "pug": "^3.0.2", "qrcode": "^1.5.3", + "read-pkg": "^8.0.0", "redis": "^4.6.7", "reflect-metadata": "0.1.13", "rxjs": "^7.8.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 69b5d7f7..1f1bee73 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -221,6 +221,9 @@ dependencies: qrcode: specifier: ^1.5.3 version: 1.5.3 + read-pkg: + specifier: ^8.0.0 + version: 8.0.0 redis: specifier: ^4.6.7 version: 4.6.7 @@ -944,7 +947,6 @@ packages: dependencies: '@babel/highlight': 7.22.10 chalk: 2.4.2 - dev: true /@babel/compat-data@7.22.9: resolution: {integrity: sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==} @@ -1086,7 +1088,6 @@ packages: '@babel/helper-validator-identifier': 7.22.5 chalk: 2.4.2 js-tokens: 4.0.0 - dev: true /@babel/parser@7.22.10: resolution: {integrity: sha512-lNbdGsQb9ekfsnjFGhEiF4hfFqGgfOP3H3d27re3n+CGhNuTSUEQdfWk556sTLNTloczcdM5TYF2LhzmDQKyvQ==} @@ -4151,7 +4152,6 @@ packages: /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} - dev: true /@types/oauth@0.9.1: resolution: {integrity: sha512-a1iY62/a3yhZ7qH7cNUsxoI3U/0Fe9+RnuFrpTKr+0WVOzbKlSLojShCKe20aOD1Sppv+i8Zlq0pLDuTJnwS4A==} @@ -4856,7 +4856,6 @@ packages: engines: {node: '>=4'} dependencies: color-convert: 1.9.3 - dev: true /ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} @@ -5471,7 +5470,6 @@ packages: ansi-styles: 3.2.1 escape-string-regexp: 1.0.5 supports-color: 5.5.0 - dev: true /chalk@3.0.0: resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==} @@ -5677,7 +5675,6 @@ packages: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} dependencies: color-name: 1.1.3 - dev: true /color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} @@ -5687,7 +5684,6 @@ packages: /color-name@1.1.3: resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - dev: true /color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} @@ -6401,7 +6397,6 @@ packages: resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} dependencies: is-arrayish: 0.2.1 - dev: true /es-abstract@1.22.1: resolution: {integrity: sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw==} @@ -6491,7 +6486,6 @@ packages: /escape-string-regexp@1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} - dev: true /escape-string-regexp@2.0.0: resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} @@ -6826,6 +6820,7 @@ packages: /event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} + requiresBuild: true dev: false /eventemitter3@3.1.2: @@ -7774,7 +7769,6 @@ packages: /has-flag@3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} - dev: true /has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} @@ -7851,6 +7845,13 @@ packages: resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} dev: true + /hosted-git-info@6.1.1: + resolution: {integrity: sha512-r0EI+HBMcXadMrugk0GCQ+6BQV39PiWAZVfq7oIckeGiN7sjRGyQxPdft3nQekFTCQbYxLBH+/axZMeH8UX6+w==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dependencies: + lru-cache: 7.18.3 + dev: false + /html-encoding-sniffer@3.0.0: resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==} engines: {node: '>=12'} @@ -8114,7 +8115,6 @@ packages: /is-arrayish@0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - dev: true /is-arrayish@0.3.2: resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} @@ -8851,7 +8851,6 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: true /js-yaml@3.14.1: resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} @@ -8966,6 +8965,11 @@ packages: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: true + /json-parse-even-better-errors@3.0.0: + resolution: {integrity: sha512-iZbGHafX/59r39gPwVPRBGw0QQKnA7tte5pSMrhWOW7swGsVvVTjmfyAV9pNqk8YGT7tRCdxRu8uzcgZwoDooA==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dev: false + /json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} dev: true @@ -9239,6 +9243,11 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true + /lines-and-columns@2.0.3: + resolution: {integrity: sha512-cNOjgCnLB+FnvWWtyRTzmB3POJ+cXxTA81LoW7u8JdmhfXzriropYwpjShnz1QLLWsQwY7nIxoDmcPTwphDK9w==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: false + /linkify-it@3.0.3: resolution: {integrity: sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==} requiresBuild: true @@ -9422,6 +9431,11 @@ packages: dependencies: yallist: 4.0.0 + /lru-cache@7.18.3: + resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} + engines: {node: '>=12'} + dev: false + /lru-cache@9.1.2: resolution: {integrity: sha512-ERJq3FOzJTxBbFjZ7iDs+NiK4VI9Wz+RdrrAB8dio1oV+YvdPzUEE4QNiT2VD51DkIbCYRUUzCRkssXCHqSnKQ==} engines: {node: 14 || >=16.14} @@ -9973,6 +9987,16 @@ packages: validate-npm-package-license: 3.0.4 dev: true + /normalize-package-data@5.0.0: + resolution: {integrity: sha512-h9iPVIfrVZ9wVYQnxFgtw1ugSvGEMOlyPWWtm8BMJhnwyEL/FLbYbTY3V3PpjI/BUK67n9PEWDu6eHzu1fB15Q==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dependencies: + hosted-git-info: 6.1.1 + is-core-module: 2.13.0 + semver: 7.5.4 + validate-npm-package-license: 3.0.4 + dev: false + /normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -10260,6 +10284,17 @@ packages: lines-and-columns: 1.2.4 dev: true + /parse-json@7.0.0: + resolution: {integrity: sha512-kP+TQYAzAiVnzOlWOe0diD6L35s9bJh0SCn95PIbZFKrOYuIRQsQkeWEYxzVDuHTt9V9YqvYCJ2Qo4z9wdfZPw==} + engines: {node: '>=16'} + dependencies: + '@babel/code-frame': 7.22.10 + error-ex: 1.3.2 + json-parse-even-better-errors: 3.0.0 + lines-and-columns: 2.0.3 + type-fest: 3.13.1 + dev: false + /parse-passwd@1.0.0: resolution: {integrity: sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==} engines: {node: '>=0.10.0'} @@ -10991,6 +11026,16 @@ packages: type-fest: 0.6.0 dev: true + /read-pkg@8.0.0: + resolution: {integrity: sha512-Ajb9oSjxXBw0YyOiwtQ2dKbAA/vMnUPnY63XcCk+mXo0BwIdQEMgZLZiMWGttQHcUhUgbK0mH85ethMPKXxziw==} + engines: {node: '>=16'} + dependencies: + '@types/normalize-package-data': 2.4.1 + normalize-package-data: 5.0.0 + parse-json: 7.0.0 + type-fest: 3.13.1 + dev: false + /readable-stream@1.1.14: resolution: {integrity: sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==} dependencies: @@ -11629,22 +11674,18 @@ packages: dependencies: spdx-expression-parse: 3.0.1 spdx-license-ids: 3.0.13 - dev: true /spdx-exceptions@2.3.0: resolution: {integrity: sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==} - dev: true /spdx-expression-parse@3.0.1: resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==} dependencies: spdx-exceptions: 2.3.0 spdx-license-ids: 3.0.13 - dev: true /spdx-license-ids@3.0.13: resolution: {integrity: sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==} - dev: true /split-on-first@1.1.0: resolution: {integrity: sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==} @@ -11908,7 +11949,6 @@ packages: engines: {node: '>=4'} dependencies: has-flag: 3.0.0 - dev: true /supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} @@ -12441,6 +12481,11 @@ packages: resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} engines: {node: '>=12.20'} + /type-fest@3.13.1: + resolution: {integrity: sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==} + engines: {node: '>=14.16'} + dev: false + /type-is@1.6.18: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} engines: {node: '>= 0.6'} @@ -12650,7 +12695,6 @@ packages: dependencies: spdx-correct: 3.2.0 spdx-expression-parse: 3.0.1 - dev: true /validator@13.11.0: resolution: {integrity: sha512-Ii+sehpSfZy+At5nPdnyMhx78fEoPDkR2XW/zimHEL3MyGJQOCQ7WeP20jPYRz7ZCpcKLB21NxuXHF3bxjStBQ==} diff --git a/src/_mocks_/index.ts b/src/_mocks_/index.ts index c61f22c6..103ddb00 100644 --- a/src/_mocks_/index.ts +++ b/src/_mocks_/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import type { Request, Response } from 'express'; import type { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; import { createMock } from '@golevelup/ts-jest'; diff --git a/src/common/constant/string.constants.ts b/src/common/constant/string.constants.ts index e1405ffd..ee9ef9c5 100644 --- a/src/common/constant/string.constants.ts +++ b/src/common/constant/string.constants.ts @@ -1,5 +1,5 @@ import { capitalize } from 'helper-fns'; -import pkg from 'load-pkg'; +import { readPackageSync } from 'read-pkg'; export const REQUEST_ID_TOKEN_HEADER = 'x-request-id'; export const VERSION_VALIDATION_MESSAGE = 'Version must start with "v" followed by a number.'; @@ -11,11 +11,7 @@ export const MULTER_IMAGE_FILTER = 'Only image files are allowed!.'; export const API_UNAUTHORISED_RESPONSE = 'No auth token in request.'; // swagger constants -const packageJson: { - name: string; - version: string; - description: string; -} = pkg.sync(); +const packageJson = readPackageSync(); export const APP_NAME = packageJson.name; export const SWAGGER_API_CURRENT_VERSION = packageJson.version; diff --git a/src/common/decorators/validation/is-after.validator.ts b/src/common/decorators/validation/is-after.validator.ts index 89edc604..e5997b77 100644 --- a/src/common/decorators/validation/is-after.validator.ts +++ b/src/common/decorators/validation/is-after.validator.ts @@ -13,7 +13,7 @@ import { isAfter } from 'date-fns'; class IsAfterConstraint implements ValidatorConstraintInterface { async validate(value: string, arguments_: ValidationArguments) { const [relatedPropertyName] = arguments_.constraints; - const relatedValue = (arguments_.object as any)[relatedPropertyName]; + const relatedValue = (arguments_.object as any)[relatedPropertyName] as string | Date; return isAfter(new Date(value), new Date(relatedValue)); } diff --git a/src/common/decorators/validation/is-enum-field.decorator.ts b/src/common/decorators/validation/is-enum-field.decorator.ts index 626f27ca..72028dd9 100644 --- a/src/common/decorators/validation/is-enum-field.decorator.ts +++ b/src/common/decorators/validation/is-enum-field.decorator.ts @@ -21,7 +21,7 @@ export const IsEnumField = (entity: object, options_?: EnumFieldOptions) => { const decoratorsToApply = [ IsEnum(entity, { each: options.each, - message: `must be a valid enum value,${enumToString(entity)}`, + message: `must be a valid enum value,${enumToString(entity).join(',')}`, }), ]; diff --git a/src/common/decorators/validation/validation-field.generator.ts b/src/common/decorators/validation/validation-field.generator.ts index 399e10f6..0f02b48b 100644 --- a/src/common/decorators/validation/validation-field.generator.ts +++ b/src/common/decorators/validation/validation-field.generator.ts @@ -15,11 +15,12 @@ import { Sanitize, Trim } from './transform.decorator'; import { validationI18nMessage } from '@lib/i18n'; import { MinMaxLength } from '@common/decorators'; +import type { NumberFieldOptions, StringFieldOptions } from '@common/@types'; export class ValidatorFieldBuilder { private decoratorsToApply: PropertyDecorator[]; - constructor(readonly options: any) {} + constructor(readonly options: NumberFieldOptions & StringFieldOptions) {} number() { this.decoratorsToApply.push( @@ -48,11 +49,11 @@ export class ValidatorFieldBuilder { return this; } - enum(entity: object) { + enum(entity: Record) { this.decoratorsToApply.push( IsEnum(entity, { each: this.options.each, - message: `must be a valid enum value,${enumToString(entity)}`, + message: `must be a valid enum value,${enumToString(entity).join(',')}`, }), ); diff --git a/src/common/guards/auth.guard.ts b/src/common/guards/auth.guard.ts index 045a2ec6..058c0ca5 100644 --- a/src/common/guards/auth.guard.ts +++ b/src/common/guards/auth.guard.ts @@ -17,7 +17,7 @@ export class AuthGuard implements CanActivate { canActivate(context: ExecutionContext): boolean { const request = context.switchToHttp().getRequest(); - const token = request.headers.authorization; + const token: string = request.headers.authorization; if (!token) throw new UnauthorizedException(translate('exception.apiUnauthorizedResponse')); diff --git a/src/common/helpers/app.utils.ts b/src/common/helpers/app.utils.ts index 6467c50e..274f122b 100644 --- a/src/common/helpers/app.utils.ts +++ b/src/common/helpers/app.utils.ts @@ -36,15 +36,19 @@ export const AppUtils = { app.close().then(() => { logger.log('✅ Http server closed.'); process.exit(0); - }); + }) + .catch((error) => { + logger.error(`❌ Http server closed with error: ${error}`); + process.exit(1); + }); }, killAppWithGrace(app: INestApplication): void { - process.on('SIGINT', async () => { + process.on('SIGINT', () => { AppUtils.gracefulShutdown(app, 'SIGINT'); }); - process.on('SIGTERM', async () => { + process.on('SIGTERM', () => { AppUtils.gracefulShutdown(app, 'SIGTERM'); }); }, @@ -80,6 +84,7 @@ export const AppUtils = { for (const method of methods) { if ( HelperService.isArray(method.security) +// eslint-disable-next-line @typescript-eslint/no-unsafe-call && method.security.includes(IS_PUBLIC_KEY_META) ) method.security = []; diff --git a/src/common/interceptors/request-sanitizer.interceptor.ts b/src/common/interceptors/request-sanitizer.interceptor.ts index a96fba86..216ea713 100644 --- a/src/common/interceptors/request-sanitizer.interceptor.ts +++ b/src/common/interceptors/request-sanitizer.interceptor.ts @@ -19,7 +19,7 @@ export class RequestSanitizerInterceptor implements NestInterceptor { // we wont be sending body on GET and DELETE requests if (!['GET', 'DELETE'].includes(request.method)) - request.body = this.cleanObject(request.body); + request.body = this.cleanObject(request.body as Record); } cleanObject(object: Record | null | undefined) { @@ -32,9 +32,9 @@ export class RequestSanitizerInterceptor implements NestInterceptor { // If the value is another nested object we need to recursively // clean it too. This will work for both array and object. if (typeof value === 'object') { - this.cleanObject(value); + this.cleanObject(value as Record); } - else { + else if (typeof value === 'string') { // If the value is not an object then it's a scalar // so we just let it be transformed. object[key] = this.transform(key, value); diff --git a/src/lib/crud/crud.service.ts b/src/lib/crud/crud.service.ts index a1e2c646..10bbf18a 100644 --- a/src/lib/crud/crud.service.ts +++ b/src/lib/crud/crud.service.ts @@ -1,4 +1,4 @@ -import type { EntityData, RequiredEntityData } from '@mikro-orm/core'; +import type { EntityData, FilterQuery, RequiredEntityData } from '@mikro-orm/core'; import { NotFoundException } from '@nestjs/common'; import type { Observable } from 'rxjs'; import { from, map, mergeMap, of, switchMap, throwError } from 'rxjs'; @@ -18,10 +18,10 @@ import { translate } from '@lib/i18n'; export abstract class BaseService< Entity extends BaseEntity, -paginationRequest extends PaginationRequest, +PRequest extends PaginationRequest, CreateDto extends RequiredEntityData = RequiredEntityData, UpdateDto extends EntityData = EntityData, -> implements Crud { +> implements Crud { protected searchField: keyof Entity; protected queryName = 'entity'; @@ -88,7 +88,7 @@ UpdateDto extends EntityData = EntityData, * @param {string} index - The name of the index to search. */ findOne(index: string): Observable { - return from(this.repository.findOne({ idx: index } as any)).pipe( + return from(this.repository.findOne({ idx: index } as FilterQuery)).pipe( mergeMap((entity) => { if (!entity) { return throwError( diff --git a/src/lib/firebase-admin/firebase.service.ts b/src/lib/firebase-admin/firebase.service.ts index 05258878..6be7e4cc 100644 --- a/src/lib/firebase-admin/firebase.service.ts +++ b/src/lib/firebase-admin/firebase.service.ts @@ -11,7 +11,7 @@ interface NestFirebase { @Injectable() export class NestFirebaseService implements NestFirebase { - private _firebaseConnection: any; + private _firebaseConnection: admin.app.App; constructor( @Inject(MODULE_OPTIONS_TOKEN) private _NestFirebaseOptions: FirebaseModuleOptions,