Skip to content

Commit

Permalink
fix: package update wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gobeam committed Jul 17, 2024
1 parent 8243179 commit 4a00059
Show file tree
Hide file tree
Showing 8 changed files with 1,999 additions and 2,753 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
100 changes: 58 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,97 +36,113 @@
"prepare": "husky install"
},
"dependencies": {
"@aws-sdk/client-cloudwatch-logs": "^3.454.0",
"@aws-sdk/client-cloudwatch-logs": "^3.496.0",
"@faker-js/faker": "^8.3.1",
"@nestjs-modules/mailer": "^1.9.1",
"@nestjs-modules/mailer": "^1.10.3",
"@nestjs/bull": "^10.0.1",
"@nestjs/common": "^10.2.10",
"@nestjs/core": "^10.2.10",
"@nestjs/common": "^10.3.0",
"@nestjs/core": "^10.3.0",
"@nestjs/jwt": "^10.2.0",
"@nestjs/mapped-types": "^2.0.4",
"@nestjs/passport": "^10.0.2",
"@nestjs/platform-express": "^10.2.10",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.3.0",
"@nestjs/serve-static": "^4.0.0",
"@nestjs/swagger": "^7.1.16",
"@nestjs/throttler": "^5.0.1",
"@nestjs/swagger": "^7.2.0",
"@nestjs/throttler": "^5.1.1",
"@nestjs/typeorm": "^10.0.1",
"@types/cookie-parser": "^1.4.6",
"aws-sdk": "^2.1502.0",
"aws-sdk": "^2.1540.0",
"bcrypt": "^5.1.1",
"bull": "^4.11.5",
"bull": "^4.12.2",
"class-transformer": "^0.5.1",
"class-validator": "0.14.0",
"config": "^3.3.9",
"class-validator": "0.14.1",
"config": "^3.3.10",
"cookie-parser": "^1.4.6",
"coveralls": "^3.1.1",
"helmet": "^7.1.0",
"ioredis": "^5.3.2",
"nest-winston": "^1.9.4",
"nestjs-i18n": "^10.3.7",
"nestjs-i18n": "^10.4.0",
"nestjs-throttler-storage-redis": "^0.4.1",
"nodemailer": "^6.9.7",
"nodemailer": "^6.9.8",
"otplib": "^12.0.1",
"passport": "^0.6.0",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"pg": "^8.11.3",
"pug": "^3.0.2",
"qrcode": "^1.5.3",
"rate-limiter-flexible": "^3.0.4",
"reflect-metadata": "^0.1.13",
"rate-limiter-flexible": "^4.0.0",
"reflect-metadata": "^0.2.1",
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.0",
"typeorm": "^0.3.17",
"typeorm": "^0.3.19",
"ua-parser-js": "^1.0.37",
"uuid": "^9.0.1",
"winston": "^3.11.0",
"winston-cloudwatch": "^6.2.0"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@nestjs/cli": "^10.2.1",
"@nestjs/schematics": "^10.0.3",
"@nestjs/testing": "^10.2.10",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@nestjs/cli": "^10.3.0",
"@nestjs/schematics": "^10.1.0",
"@nestjs/testing": "^10.3.0",
"@types/bull": "^4.10.0",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.10",
"@types/jest": "^29.5.11",
"@types/multer": "^1.4.11",
"@types/node": "20.10.0",
"@types/passport-jwt": "^3.0.13",
"@types/supertest": "^2.0.16",
"@types/node": "20.11.5",
"@types/passport-jwt": "^4.0.0",
"@types/supertest": "^6.0.2",
"@types/ua-parser-js": "^0.7.39",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lint-staged": "^15.1.0",
"prettier": "^3.1.0",
"lint-staged": "^15.2.0",
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"supertest": "^6.3.3",
"supertest": "^6.3.4",
"ts-jest": "^29.1.1",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.2"
"typescript": "^5.3.3"
},
"engines" : {
"node" : "^18.13.0 || >=20.9.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"moduleDirectories": [
"node_modules",
"src"
],
"rootDir": ".",
"modulePaths": [
"<rootDir>"
],
"testRegex": ".*-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
"test/**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"coverageDirectory": "./coverage",
"testEnvironment": "node",
"coverageReporters": [
"lcov",
"json",
"text",
"html"
]
}
}
25 changes: 10 additions & 15 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ export class AuthService {

const [user, error, code] = await this.userRepository.login(userLoginDto);
if (!user) {
const [result, throttleError] = await this.limitConsumerPromiseHandler(
usernameIPkey
);
const [result, throttleError] =
await this.limitConsumerPromiseHandler(usernameIPkey);
if (!result) {
throw new CustomHttpException(
`tooManyRequest-{"second":${String(
Expand Down Expand Up @@ -295,9 +294,8 @@ export class AuthService {
[field]: updateUserDto[field]
};
condition.id = Not(id);
const checkUnique = await this.userRepository.countEntityByCondition(
condition
);
const checkUnique =
await this.userRepository.countEntityByCondition(condition);
if (checkUnique > 0) {
errorPayload.push({
property: field,
Expand Down Expand Up @@ -377,9 +375,8 @@ export class AuthService {
*/
async resetPassword(resetPasswordDto: ResetPasswordDto): Promise<void> {
const { password } = resetPasswordDto;
const user = await this.userRepository.getUserForResetPassword(
resetPasswordDto
);
const user =
await this.userRepository.getUserForResetPassword(resetPasswordDto);
if (!user) {
throw new NotFoundException();
}
Expand Down Expand Up @@ -453,9 +450,8 @@ export class AuthService {
const condition: ObjectLiteral = {
token
};
const tokenCount = await this.userRepository.countEntityByCondition(
condition
);
const tokenCount =
await this.userRepository.countEntityByCondition(condition);
if (tokenCount > 0) {
await this.generateUniqueToken(length);
}
Expand Down Expand Up @@ -524,9 +520,8 @@ export class AuthService {
async revokeRefreshToken(encoded: string): Promise<void> {
// ignore exception because anyway we are going invalidate cookies
try {
const { token } = await this.refreshTokenService.resolveRefreshToken(
encoded
);
const { token } =
await this.refreshTokenService.resolveRefreshToken(encoded);
if (token) {
token.isRevoked = true;
await token.save();
Expand Down
5 changes: 2 additions & 3 deletions src/email-template/email-template.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ export class EmailTemplateService
title: updateEmailTemplateDto.title
};
condition.id = Not(id);
const countSameDescription = await this.repository.countEntityByCondition(
condition
);
const countSameDescription =
await this.repository.countEntityByCondition(condition);
if (countSameDescription > 0) {
throw new UnprocessableEntityException({
property: 'title',
Expand Down
5 changes: 2 additions & 3 deletions src/permission/permissions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ export class PermissionsService
description: updatePermissionDto.description
};
condition.id = Not(id);
const countSameDescription = await this.repository.countEntityByCondition(
condition
);
const countSameDescription =
await this.repository.countEntityByCondition(condition);
if (countSameDescription > 0) {
throw new UnprocessableEntityException({
property: 'name',
Expand Down
5 changes: 2 additions & 3 deletions src/role/roles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ export class RolesService implements CommonServiceInterface<RoleSerializer> {
name: updateRoleDto.name
};
condition.id = Not(id);
const checkUniqueTitle = await this.repository.countEntityByCondition(
condition
);
const checkUniqueTitle =
await this.repository.countEntityByCondition(condition);
if (checkUniqueTitle > 0) {
throw new UnprocessableEntityException({
property: 'name',
Expand Down
16 changes: 13 additions & 3 deletions test/factories/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ThrottlerModule } from '@nestjs/throttler';
import { INestApplication } from '@nestjs/common';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { DataSource } from 'typeorm';
import { ThrottlerStorageRedisService } from 'nestjs-throttler-storage-redis';
import Redis from 'ioredis';

import { AppModule } from 'src/app.module';
import { AppDataSource } from 'src/config/ormconfig';
import assert from 'assert';

export class AppFactory {
private constructor(
Expand All @@ -33,7 +34,14 @@ export class AppFactory {
return {
ttl: 60,
limit: 60,
storage: new ThrottlerStorageRedisService(redis)
storage: new ThrottlerStorageRedisService(redis),
throttlers: [
{
name: 'test',
ttl: 60,
limit: 60
}
]
};
}
})
Expand Down Expand Up @@ -72,7 +80,9 @@ export class AppFactory {
);
}
}
await this.redis.flushall();
if ((await this.redis.ping()) === 'PONG') {
await this.redis.flushall();
}
}
}

Expand Down
Loading

0 comments on commit 4a00059

Please sign in to comment.