Skip to content

Commit

Permalink
fix: pkg update
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin committed Aug 15, 2023
1 parent 8525d9b commit 760207f
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
80 changes: 62 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/_mocks_/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
8 changes: 2 additions & 6 deletions src/common/constant/string.constants.ts
Original file line number Diff line number Diff line change
@@ -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.';
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/common/decorators/validation/is-after.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(',')}`,
}),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -48,11 +49,11 @@ export class ValidatorFieldBuilder {
return this;
}

enum(entity: object) {
enum(entity: Record<any, any>) {
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(',')}`,
}),
);

Expand Down
2 changes: 1 addition & 1 deletion src/common/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Loading

0 comments on commit 760207f

Please sign in to comment.