typescript-express-starter 9.1.2 → 9.2.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 (50) hide show
  1. package/README.kr.md +6 -0
  2. package/README.md +6 -0
  3. package/lib/default/jest.config.js +1 -1
  4. package/lib/default/package.json +39 -39
  5. package/lib/default/src/services/auth.service.ts +6 -6
  6. package/lib/default/src/services/users.service.ts +6 -6
  7. package/lib/graphql/jest.config.js +1 -1
  8. package/lib/graphql/package.json +42 -42
  9. package/lib/graphql/src/repositories/auth.repository.ts +7 -7
  10. package/lib/graphql/src/repositories/users.repository.ts +8 -8
  11. package/lib/knex/jest.config.js +1 -1
  12. package/lib/knex/knexfile.ts +4 -2
  13. package/lib/knex/package.json +42 -42
  14. package/lib/knex/src/databases/migrations/20210713110926_initial.ts +1 -1
  15. package/lib/knex/src/services/auth.service.ts +7 -7
  16. package/lib/knex/src/services/users.service.ts +6 -6
  17. package/lib/mikro-orm/package.json +40 -40
  18. package/lib/mikro-orm/src/services/auth.service.ts +7 -7
  19. package/lib/mikro-orm/src/services/users.service.ts +8 -8
  20. package/lib/mongoose/jest.config.js +1 -1
  21. package/lib/mongoose/package.json +41 -41
  22. package/lib/mongoose/src/databases/index.ts +1 -2
  23. package/lib/mongoose/src/services/auth.service.ts +7 -7
  24. package/lib/mongoose/src/services/users.service.ts +8 -8
  25. package/lib/prisma/jest.config.js +1 -1
  26. package/lib/prisma/package.json +41 -41
  27. package/lib/prisma/src/services/auth.service.ts +7 -7
  28. package/lib/prisma/src/services/users.service.ts +8 -8
  29. package/lib/routing-controllers/jest.config.js +1 -1
  30. package/lib/routing-controllers/package.json +40 -40
  31. package/lib/routing-controllers/src/services/auth.service.ts +7 -7
  32. package/lib/routing-controllers/src/services/users.service.ts +6 -6
  33. package/lib/sequelize/jest.config.js +1 -1
  34. package/lib/sequelize/package.json +43 -43
  35. package/lib/sequelize/src/services/auth.service.ts +7 -7
  36. package/lib/sequelize/src/services/users.service.ts +8 -8
  37. package/lib/starter.js +4 -4
  38. package/lib/typegoose/jest.config.js +1 -1
  39. package/lib/typegoose/package.json +39 -39
  40. package/lib/typegoose/src/middlewares/validation.middleware.ts +3 -3
  41. package/lib/typegoose/src/services/auth.service.ts +7 -7
  42. package/lib/typegoose/src/services/users.service.ts +8 -8
  43. package/lib/typeorm/jest.config.js +1 -1
  44. package/lib/typeorm/package.json +41 -41
  45. package/lib/typeorm/src/databases/index.ts +1 -1
  46. package/lib/typeorm/src/services/auth.service.ts +7 -7
  47. package/lib/typeorm/src/services/users.service.ts +8 -8
  48. package/lib/typeorm/src/tests/auth.test.ts +5 -6
  49. package/lib/typeorm/src/tests/users.test.ts +29 -33
  50. package/package.json +2 -3
@@ -13,19 +13,19 @@ class UserService {
13
13
  }
14
14
 
15
15
  public async findUserById(userId: number): Promise<User> {
16
- if (isEmpty(userId)) throw new HttpException(400, "You're not userId");
16
+ if (isEmpty(userId)) throw new HttpException(400, "UserId is empty");
17
17
 
18
18
  const findUser: User = await this.users.findUnique({ where: { id: userId } });
19
- if (!findUser) throw new HttpException(409, "You're not user");
19
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
20
20
 
21
21
  return findUser;
22
22
  }
23
23
 
24
24
  public async createUser(userData: CreateUserDto): Promise<User> {
25
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
25
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
26
26
 
27
27
  const findUser: User = await this.users.findUnique({ where: { email: userData.email } });
28
- if (findUser) throw new HttpException(409, `You're email ${userData.email} already exists`);
28
+ if (findUser) throw new HttpException(409, `This email ${userData.email} already exists`);
29
29
 
30
30
  const hashedPassword = await hash(userData.password, 10);
31
31
  const createUserData: User = await this.users.create({ data: { ...userData, password: hashedPassword } });
@@ -33,10 +33,10 @@ class UserService {
33
33
  }
34
34
 
35
35
  public async updateUser(userId: number, userData: CreateUserDto): Promise<User> {
36
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
36
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
37
37
 
38
38
  const findUser: User = await this.users.findUnique({ where: { id: userId } });
39
- if (!findUser) throw new HttpException(409, "You're not user");
39
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
40
40
 
41
41
  const hashedPassword = await hash(userData.password, 10);
42
42
  const updateUserData = await this.users.update({ where: { id: userId }, data: { ...userData, password: hashedPassword } });
@@ -44,10 +44,10 @@ class UserService {
44
44
  }
45
45
 
46
46
  public async deleteUser(userId: number): Promise<User> {
47
- if (isEmpty(userId)) throw new HttpException(400, "You're not userId");
47
+ if (isEmpty(userId)) throw new HttpException(400, "User doesn't existId");
48
48
 
49
49
  const findUser: User = await this.users.findUnique({ where: { id: userId } });
50
- if (!findUser) throw new HttpException(409, "You're not user");
50
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
51
51
 
52
52
  const deleteUserData = await this.users.delete({ where: { id: userId } });
53
53
  return deleteUserData;
@@ -1,4 +1,4 @@
1
- const { pathsToModuleNameMapper } = require('ts-jest/utils');
1
+ const { pathsToModuleNameMapper } = require('ts-jest');
2
2
  const { compilerOptions } = require('./tsconfig.json');
3
3
 
4
4
  module.exports = {
@@ -18,59 +18,59 @@
18
18
  "dependencies": {
19
19
  "bcrypt": "^5.0.1",
20
20
  "class-transformer": "^0.5.1",
21
- "class-validator": "^0.13.1",
22
- "class-validator-jsonschema": "^3.0.2",
21
+ "class-validator": "^0.13.2",
22
+ "class-validator-jsonschema": "^3.1.1",
23
23
  "compression": "^1.7.4",
24
- "cookie-parser": "^1.4.5",
24
+ "cookie-parser": "^1.4.6",
25
25
  "cors": "^2.8.5",
26
- "dotenv": "^10.0.0",
27
- "envalid": "^7.1.0",
28
- "express": "^4.17.1",
29
- "helmet": "^4.6.0",
26
+ "dotenv": "^16.0.1",
27
+ "envalid": "^7.3.1",
28
+ "express": "^4.18.1",
29
+ "helmet": "^5.1.1",
30
30
  "hpp": "^0.2.3",
31
31
  "jsonwebtoken": "^8.5.1",
32
32
  "morgan": "^1.10.0",
33
33
  "reflect-metadata": "^0.1.13",
34
34
  "routing-controllers": "^0.9.0",
35
- "routing-controllers-openapi": "^3.0.0",
36
- "swagger-ui-express": "^4.1.6",
37
- "winston": "^3.3.3",
38
- "winston-daily-rotate-file": "^4.5.5"
35
+ "routing-controllers-openapi": "^3.1.0",
36
+ "swagger-ui-express": "^4.5.0",
37
+ "winston": "^3.8.1",
38
+ "winston-daily-rotate-file": "^4.7.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@swc/cli": "^0.1.51",
42
- "@swc/core": "^1.2.108",
41
+ "@swc/cli": "^0.1.57",
42
+ "@swc/core": "^1.2.220",
43
43
  "@types/bcrypt": "^5.0.0",
44
- "@types/compression": "^1.7.1",
45
- "@types/cookie-parser": "^1.4.2",
46
- "@types/cors": "^2.8.11",
44
+ "@types/compression": "^1.7.2",
45
+ "@types/cookie-parser": "^1.4.3",
46
+ "@types/cors": "^2.8.12",
47
47
  "@types/express": "^4.17.13",
48
- "@types/hpp": "^0.2.1",
49
- "@types/jest": "27.4.x",
50
- "@types/jsonwebtoken": "^8.5.4",
48
+ "@types/hpp": "^0.2.2",
49
+ "@types/jest": "^28.1.6",
50
+ "@types/jsonwebtoken": "^8.5.8",
51
51
  "@types/morgan": "^1.9.3",
52
- "@types/node": "^16.0.1",
53
- "@types/supertest": "^2.0.11",
52
+ "@types/node": "^17.0.45",
53
+ "@types/supertest": "^2.0.12",
54
54
  "@types/swagger-ui-express": "^4.1.3",
55
- "@typescript-eslint/eslint-plugin": "^4.28.2",
56
- "@typescript-eslint/parser": "^4.28.2",
55
+ "@typescript-eslint/eslint-plugin": "^5.29.0",
56
+ "@typescript-eslint/parser": "^5.29.0",
57
57
  "cross-env": "^7.0.3",
58
- "eslint": "^7.30.0",
59
- "eslint-config-prettier": "^8.3.0",
60
- "eslint-plugin-prettier": "^3.4.0",
61
- "husky": "^7.0.1",
62
- "jest": "27.4.x",
63
- "lint-staged": "^11.0.0",
58
+ "eslint": "^8.20.0",
59
+ "eslint-config-prettier": "^8.5.0",
60
+ "eslint-plugin-prettier": "^4.2.1",
61
+ "husky": "^8.0.1",
62
+ "jest": "^28.1.1",
63
+ "lint-staged": "^13.0.3",
64
64
  "node-config": "^0.0.2",
65
- "node-gyp": "^8.1.0",
66
- "nodemon": "^2.0.9",
67
- "pm2": "^5.1.0",
68
- "prettier": "^2.3.2",
69
- "supertest": "^6.2.2",
70
- "ts-jest": "^27.1.4",
71
- "ts-node": "^10.4.0",
72
- "tsc-alias": "^1.4.1",
73
- "tsconfig-paths": "^3.10.1",
74
- "typescript": "^4.5.2"
65
+ "node-gyp": "^9.1.0",
66
+ "nodemon": "^2.0.19",
67
+ "pm2": "^5.2.0",
68
+ "prettier": "^2.7.1",
69
+ "supertest": "^6.2.4",
70
+ "ts-jest": "^28.0.7",
71
+ "ts-node": "^10.9.1",
72
+ "tsc-alias": "^1.7.0",
73
+ "tsconfig-paths": "^4.0.0",
74
+ "typescript": "^4.7.4"
75
75
  }
76
- }
76
+ }
@@ -12,10 +12,10 @@ class AuthService {
12
12
  public users = userModel;
13
13
 
14
14
  public async signup(userData: CreateUserDto): Promise<User> {
15
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
15
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
16
16
 
17
17
  const findUser: User = this.users.find(user => user.email === userData.email);
18
- if (findUser) throw new HttpException(409, `You're email ${userData.email} already exists`);
18
+ if (findUser) throw new HttpException(409, `This email ${userData.email} already exists`);
19
19
 
20
20
  const hashedPassword = await hash(userData.password, 10);
21
21
  const createUserData: User = { id: this.users.length + 1, ...userData, password: hashedPassword };
@@ -24,13 +24,13 @@ class AuthService {
24
24
  }
25
25
 
26
26
  public async login(userData: CreateUserDto): Promise<{ cookie: string; findUser: User }> {
27
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
27
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
28
28
 
29
29
  const findUser: User = this.users.find(user => user.email === userData.email);
30
- if (!findUser) throw new HttpException(409, `You're email ${userData.email} not found`);
30
+ if (!findUser) throw new HttpException(409, `This email ${userData.email} was not found`);
31
31
 
32
32
  const isPasswordMatching: boolean = await compare(userData.password, findUser.password);
33
- if (!isPasswordMatching) throw new HttpException(409, "You're password not matching");
33
+ if (!isPasswordMatching) throw new HttpException(409, "Password is not matching");
34
34
 
35
35
  const tokenData = this.createToken(findUser);
36
36
  const cookie = this.createCookie(tokenData);
@@ -39,10 +39,10 @@ class AuthService {
39
39
  }
40
40
 
41
41
  public async logout(userData: User): Promise<User> {
42
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
42
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
43
43
 
44
44
  const findUser: User = this.users.find(user => user.email === userData.email && user.password === userData.password);
45
- if (!findUser) throw new HttpException(409, "You're not user");
45
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
46
46
 
47
47
  return findUser;
48
48
  }
@@ -15,16 +15,16 @@ class UserService {
15
15
 
16
16
  public async findUserById(userId: number): Promise<User> {
17
17
  const findUser: User = this.users.find(user => user.id === userId);
18
- if (!findUser) throw new HttpException(409, "You're not user");
18
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
19
19
 
20
20
  return findUser;
21
21
  }
22
22
 
23
23
  public async createUser(userData: CreateUserDto): Promise<User> {
24
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
24
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
25
25
 
26
26
  const findUser: User = this.users.find(user => user.email === userData.email);
27
- if (findUser) throw new HttpException(409, `Your email ${userData.email} already exists`);
27
+ if (findUser) throw new HttpException(409, `This email ${userData.email} already exists`);
28
28
 
29
29
  const hashedPassword = await hash(userData.password, 10);
30
30
  const createUserData: User = { id: this.users.length + 1, ...userData, password: hashedPassword };
@@ -34,10 +34,10 @@ class UserService {
34
34
  }
35
35
 
36
36
  public async updateUser(userId: number, userData: CreateUserDto): Promise<User[]> {
37
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
37
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
38
38
 
39
39
  const findUser: User = this.users.find(user => user.id === userId);
40
- if (!findUser) throw new HttpException(409, "You're not user");
40
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
41
41
 
42
42
  const hashedPassword = await hash(userData.password, 10);
43
43
  const updateUserData: User[] = this.users.map((user: User) => {
@@ -50,7 +50,7 @@ class UserService {
50
50
 
51
51
  public async deleteUser(userId: number): Promise<User[]> {
52
52
  const findUser: User = this.users.find(user => user.id === userId);
53
- if (!findUser) throw new HttpException(409, "You're not user");
53
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
54
54
 
55
55
  const deleteUserData: User[] = this.users.filter(user => user.id !== findUser.id);
56
56
  return deleteUserData;
@@ -1,4 +1,4 @@
1
- const { pathsToModuleNameMapper } = require('ts-jest/utils');
1
+ const { pathsToModuleNameMapper } = require('ts-jest');
2
2
  const { compilerOptions } = require('./tsconfig.json');
3
3
 
4
4
  module.exports = {
@@ -18,61 +18,61 @@
18
18
  "dependencies": {
19
19
  "bcrypt": "^5.0.1",
20
20
  "class-transformer": "^0.5.1",
21
- "class-validator": "^0.13.1",
21
+ "class-validator": "^0.13.2",
22
22
  "compression": "^1.7.4",
23
- "cookie-parser": "^1.4.5",
23
+ "cookie-parser": "^1.4.6",
24
24
  "cors": "^2.8.5",
25
- "dotenv": "^10.0.0",
26
- "envalid": "^7.1.0",
27
- "express": "^4.17.1",
28
- "helmet": "^4.6.0",
25
+ "dotenv": "^16.0.1",
26
+ "envalid": "^7.3.1",
27
+ "express": "^4.18.1",
28
+ "helmet": "^5.1.1",
29
29
  "hpp": "^0.2.3",
30
30
  "jsonwebtoken": "^8.5.1",
31
31
  "morgan": "^1.10.0",
32
- "mysql2": "^2.2.5",
33
- "sequelize": "^6.6.5",
34
- "swagger-jsdoc": "^6.0.0",
35
- "swagger-ui-express": "^4.1.6",
36
- "winston": "^3.3.3",
37
- "winston-daily-rotate-file": "^4.5.5"
32
+ "mysql2": "^2.3.3",
33
+ "sequelize": "^6.21.3",
34
+ "swagger-jsdoc": "^6.2.1",
35
+ "swagger-ui-express": "^4.5.0",
36
+ "winston": "^3.8.1",
37
+ "winston-daily-rotate-file": "^4.7.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@swc/cli": "^0.1.51",
41
- "@swc/core": "^1.2.108",
40
+ "@swc/cli": "^0.1.57",
41
+ "@swc/core": "^1.2.220",
42
42
  "@types/bcrypt": "^5.0.0",
43
- "@types/compression": "^1.7.1",
44
- "@types/cookie-parser": "^1.4.2",
45
- "@types/cors": "^2.8.11",
43
+ "@types/compression": "^1.7.2",
44
+ "@types/cookie-parser": "^1.4.3",
45
+ "@types/cors": "^2.8.12",
46
46
  "@types/express": "^4.17.13",
47
- "@types/hpp": "^0.2.1",
48
- "@types/jest": "27.4.x",
49
- "@types/jsonwebtoken": "^8.5.4",
47
+ "@types/hpp": "^0.2.2",
48
+ "@types/jest": "^28.1.6",
49
+ "@types/jsonwebtoken": "^8.5.8",
50
50
  "@types/morgan": "^1.9.3",
51
- "@types/node": "^16.0.1",
52
- "@types/sequelize": "^4.28.10",
53
- "@types/supertest": "^2.0.11",
51
+ "@types/node": "^17.0.45",
52
+ "@types/sequelize": "^4.28.14",
53
+ "@types/supertest": "^2.0.12",
54
54
  "@types/swagger-jsdoc": "^6.0.1",
55
55
  "@types/swagger-ui-express": "^4.1.3",
56
- "@typescript-eslint/eslint-plugin": "^4.28.2",
57
- "@typescript-eslint/parser": "^4.28.2",
56
+ "@typescript-eslint/eslint-plugin": "^5.29.0",
57
+ "@typescript-eslint/parser": "^5.29.0",
58
58
  "cross-env": "^7.0.3",
59
- "eslint": "^7.30.0",
60
- "eslint-config-prettier": "^8.3.0",
61
- "eslint-plugin-prettier": "^3.4.0",
62
- "husky": "^7.0.1",
63
- "jest": "27.4.x",
64
- "lint-staged": "^11.0.0",
59
+ "eslint": "^8.20.0",
60
+ "eslint-config-prettier": "^8.5.0",
61
+ "eslint-plugin-prettier": "^4.2.1",
62
+ "husky": "^8.0.1",
63
+ "jest": "^28.1.1",
64
+ "lint-staged": "^13.0.3",
65
65
  "node-config": "^0.0.2",
66
- "node-gyp": "^8.1.0",
67
- "nodemon": "^2.0.9",
68
- "pm2": "^5.1.0",
69
- "prettier": "^2.3.2",
70
- "sequelize-cli": "^6.2.0",
71
- "supertest": "^6.2.2",
72
- "ts-jest": "^27.1.4",
73
- "ts-node": "^10.4.0",
74
- "tsc-alias": "^1.4.1",
75
- "tsconfig-paths": "^3.10.1",
76
- "typescript": "^4.5.2"
66
+ "node-gyp": "^9.1.0",
67
+ "nodemon": "^2.0.19",
68
+ "pm2": "^5.2.0",
69
+ "prettier": "^2.7.1",
70
+ "sequelize-cli": "^6.4.1",
71
+ "supertest": "^6.2.4",
72
+ "ts-jest": "^28.0.7",
73
+ "ts-node": "^10.9.1",
74
+ "tsc-alias": "^1.7.0",
75
+ "tsconfig-paths": "^4.0.0",
76
+ "typescript": "^4.7.4"
77
77
  }
78
- }
78
+ }
@@ -12,10 +12,10 @@ class AuthService {
12
12
  public users = DB.Users;
13
13
 
14
14
  public async signup(userData: CreateUserDto): Promise<User> {
15
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
15
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
16
16
 
17
17
  const findUser: User = await this.users.findOne({ where: { email: userData.email } });
18
- if (findUser) throw new HttpException(409, `You're email ${userData.email} already exists`);
18
+ if (findUser) throw new HttpException(409, `This email ${userData.email} already exists`);
19
19
 
20
20
  const hashedPassword = await hash(userData.password, 10);
21
21
  const createUserData: User = await this.users.create({ ...userData, password: hashedPassword });
@@ -24,13 +24,13 @@ class AuthService {
24
24
  }
25
25
 
26
26
  public async login(userData: CreateUserDto): Promise<{ cookie: string; findUser: User }> {
27
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
27
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
28
28
 
29
29
  const findUser: User = await this.users.findOne({ where: { email: userData.email } });
30
- if (!findUser) throw new HttpException(409, `You're email ${userData.email} not found`);
30
+ if (!findUser) throw new HttpException(409, `This email ${userData.email} was not found`);
31
31
 
32
32
  const isPasswordMatching: boolean = await compare(userData.password, findUser.password);
33
- if (!isPasswordMatching) throw new HttpException(409, "You're password not matching");
33
+ if (!isPasswordMatching) throw new HttpException(409, "Password not matching");
34
34
 
35
35
  const tokenData = this.createToken(findUser);
36
36
  const cookie = this.createCookie(tokenData);
@@ -39,10 +39,10 @@ class AuthService {
39
39
  }
40
40
 
41
41
  public async logout(userData: User): Promise<User> {
42
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
42
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
43
43
 
44
44
  const findUser: User = await this.users.findOne({ where: { email: userData.email, password: userData.password } });
45
- if (!findUser) throw new HttpException(409, "You're not user");
45
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
46
46
 
47
47
  return findUser;
48
48
  }
@@ -14,19 +14,19 @@ class UserService {
14
14
  }
15
15
 
16
16
  public async findUserById(userId: number): Promise<User> {
17
- if (isEmpty(userId)) throw new HttpException(400, "You're not userId");
17
+ if (isEmpty(userId)) throw new HttpException(400, "UserId is empty");
18
18
 
19
19
  const findUser: User = await this.users.findByPk(userId);
20
- if (!findUser) throw new HttpException(409, "You're not user");
20
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
21
21
 
22
22
  return findUser;
23
23
  }
24
24
 
25
25
  public async createUser(userData: CreateUserDto): Promise<User> {
26
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
26
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
27
27
 
28
28
  const findUser: User = await this.users.findOne({ where: { email: userData.email } });
29
- if (findUser) throw new HttpException(409, `You're email ${userData.email} already exists`);
29
+ if (findUser) throw new HttpException(409, `This email ${userData.email} already exists`);
30
30
 
31
31
  const hashedPassword = await hash(userData.password, 10);
32
32
  const createUserData: User = await this.users.create({ ...userData, password: hashedPassword });
@@ -34,10 +34,10 @@ class UserService {
34
34
  }
35
35
 
36
36
  public async updateUser(userId: number, userData: CreateUserDto): Promise<User> {
37
- if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
37
+ if (isEmpty(userData)) throw new HttpException(400, "userData is empty");
38
38
 
39
39
  const findUser: User = await this.users.findByPk(userId);
40
- if (!findUser) throw new HttpException(409, "You're not user");
40
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
41
41
 
42
42
  const hashedPassword = await hash(userData.password, 10);
43
43
  await this.users.update({ ...userData, password: hashedPassword }, { where: { id: userId } });
@@ -47,10 +47,10 @@ class UserService {
47
47
  }
48
48
 
49
49
  public async deleteUser(userId: number): Promise<User> {
50
- if (isEmpty(userId)) throw new HttpException(400, "You're not userId");
50
+ if (isEmpty(userId)) throw new HttpException(400, "User doesn't existId");
51
51
 
52
52
  const findUser: User = await this.users.findByPk(userId);
53
- if (!findUser) throw new HttpException(409, "You're not user");
53
+ if (!findUser) throw new HttpException(409, "User doesn't exist");
54
54
 
55
55
  await this.users.destroy({ where: { id: userId } });
56
56
 
package/lib/starter.js CHANGED
@@ -101,7 +101,7 @@ const dependenciesUpdates = async () => {
101
101
  type: "confirm",
102
102
  name: "isUpdated",
103
103
  message:
104
- "Do you want to update all packages in the node_modules directory and dependency ?"
104
+ "Do you want to update all packages in the node_modules directory and dependency ?",
105
105
  },
106
106
  ]);
107
107
 
@@ -111,7 +111,7 @@ const dependenciesUpdates = async () => {
111
111
  type: "confirm",
112
112
  name: "isUpdatedReconfirm",
113
113
  message:
114
- "However, updating to the latest version may cause package dependency issues. Do you still want to update ?"
114
+ "However, updating to the latest version may cause package dependency issues. Do you still want to update ?",
115
115
  },
116
116
  ]);
117
117
 
@@ -130,12 +130,12 @@ const dependenciesDeduped = async () => {
130
130
  {
131
131
  type: "confirm",
132
132
  name: "isDeduped",
133
- message: "Used to removed duplicate packages at npm. Do you want to ?",
133
+ message: "Do you want to Used to removed duplicate packages at npm ?",
134
134
  },
135
135
  ]);
136
136
 
137
137
  return isDeduped;
138
- }
138
+ };
139
139
 
140
140
  /**
141
141
  * @method copyProjectFiles
@@ -1,4 +1,4 @@
1
- const { pathsToModuleNameMapper } = require('ts-jest/utils');
1
+ const { pathsToModuleNameMapper } = require('ts-jest');
2
2
  const { compilerOptions } = require('./tsconfig.json');
3
3
 
4
4
  module.exports = {
@@ -16,62 +16,62 @@
16
16
  "deploy:dev": "pm2 start ecosystem.config.js --only dev"
17
17
  },
18
18
  "dependencies": {
19
- "@typegoose/typegoose": "^9.4.0",
19
+ "@typegoose/typegoose": "^9.10.1",
20
20
  "bcrypt": "^5.0.1",
21
21
  "class-transformer": "^0.5.1",
22
- "class-validator": "^0.13.1",
22
+ "class-validator": "^0.13.2",
23
23
  "compression": "^1.7.4",
24
- "cookie-parser": "^1.4.5",
24
+ "cookie-parser": "^1.4.6",
25
25
  "cors": "^2.8.5",
26
- "dotenv": "^10.0.0",
27
- "envalid": "^7.1.0",
28
- "express": "^4.17.1",
29
- "helmet": "^4.6.0",
26
+ "dotenv": "^16.0.1",
27
+ "envalid": "^7.3.1",
28
+ "express": "^4.18.1",
29
+ "helmet": "^5.1.1",
30
30
  "hpp": "^0.2.3",
31
31
  "jsonwebtoken": "^8.5.1",
32
32
  "mongoose": "^6.3.2",
33
33
  "morgan": "^1.10.0",
34
- "swagger-jsdoc": "^6.0.0",
35
- "swagger-ui-express": "^4.1.6",
36
- "winston": "^3.3.3",
37
- "winston-daily-rotate-file": "^4.5.5"
34
+ "swagger-jsdoc": "^6.2.1",
35
+ "swagger-ui-express": "^4.5.0",
36
+ "winston": "^3.8.1",
37
+ "winston-daily-rotate-file": "^4.7.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@swc/cli": "^0.1.51",
41
- "@swc/core": "^1.2.108",
40
+ "@swc/cli": "^0.1.57",
41
+ "@swc/core": "^1.2.220",
42
42
  "@types/bcrypt": "^5.0.0",
43
- "@types/compression": "^1.7.1",
44
- "@types/cookie-parser": "^1.4.2",
45
- "@types/cors": "^2.8.11",
43
+ "@types/compression": "^1.7.2",
44
+ "@types/cookie-parser": "^1.4.3",
45
+ "@types/cors": "^2.8.12",
46
46
  "@types/express": "^4.17.13",
47
- "@types/hpp": "^0.2.1",
48
- "@types/jest": "27.4.x",
49
- "@types/jsonwebtoken": "^8.5.4",
47
+ "@types/hpp": "^0.2.2",
48
+ "@types/jest": "^28.1.6",
49
+ "@types/jsonwebtoken": "^8.5.8",
50
50
  "@types/mongoose": "^5.10.1",
51
51
  "@types/morgan": "^1.9.3",
52
- "@types/node": "^16.0.1",
53
- "@types/supertest": "^2.0.11",
52
+ "@types/node": "^17.0.45",
53
+ "@types/supertest": "^2.0.12",
54
54
  "@types/swagger-jsdoc": "^6.0.1",
55
55
  "@types/swagger-ui-express": "^4.1.3",
56
- "@typescript-eslint/eslint-plugin": "^4.28.2",
57
- "@typescript-eslint/parser": "^4.28.2",
56
+ "@typescript-eslint/eslint-plugin": "^5.29.0",
57
+ "@typescript-eslint/parser": "^5.29.0",
58
58
  "cross-env": "^7.0.3",
59
- "eslint": "^7.30.0",
60
- "eslint-config-prettier": "^8.3.0",
61
- "eslint-plugin-prettier": "^3.4.0",
62
- "husky": "^7.0.1",
63
- "jest": "27.4.x",
64
- "lint-staged": "^11.0.0",
59
+ "eslint": "^8.20.0",
60
+ "eslint-config-prettier": "^8.5.0",
61
+ "eslint-plugin-prettier": "^4.2.1",
62
+ "husky": "^8.0.1",
63
+ "jest": "^28.1.1",
64
+ "lint-staged": "^13.0.3",
65
65
  "node-config": "^0.0.2",
66
- "node-gyp": "^8.1.0",
67
- "nodemon": "^2.0.9",
68
- "pm2": "^5.1.0",
69
- "prettier": "^2.3.2",
70
- "supertest": "^6.2.2",
71
- "ts-jest": "^27.1.4",
72
- "ts-node": "^10.4.0",
73
- "tsc-alias": "^1.4.1",
74
- "tsconfig-paths": "^3.10.1",
75
- "typescript": "^4.5.2"
66
+ "node-gyp": "^9.1.0",
67
+ "nodemon": "^2.0.19",
68
+ "pm2": "^5.2.0",
69
+ "prettier": "^2.7.1",
70
+ "supertest": "^6.2.4",
71
+ "ts-jest": "^28.0.7",
72
+ "ts-node": "^10.9.1",
73
+ "tsc-alias": "^1.7.0",
74
+ "tsconfig-paths": "^4.0.0",
75
+ "typescript": "^4.7.4"
76
76
  }
77
77
  }
@@ -1,4 +1,4 @@
1
- import { plainToClass } from 'class-transformer';
1
+ import { plainToInstance } from 'class-transformer';
2
2
  import { validate, ValidationError } from 'class-validator';
3
3
  import { RequestHandler } from 'express';
4
4
  import { HttpException } from '@exceptions/HttpException';
@@ -11,9 +11,9 @@ const validationMiddleware = (
11
11
  forbidNonWhitelisted = true,
12
12
  ): RequestHandler => {
13
13
  return (req, res, next) => {
14
- validate(plainToClass(type, req[value]), { skipMissingProperties, whitelist, forbidNonWhitelisted }).then((errors: ValidationError[]) => {
14
+ validate(plainToInstance(type, req[value]), { skipMissingProperties, whitelist, forbidNonWhitelisted }).then((errors: ValidationError[]) => {
15
15
  if (errors.length > 0) {
16
- const message = errors.map((error: ValidationError) => Object.values(error.constraints)).join(', ');
16
+ const message = errors.map((error: ValidationError) => error.constraints ? Object.values(error.constraints) : error.children.map((error: ValidationError) => Object.values(error.constraints))).join(', ');
17
17
  next(new HttpException(400, message));
18
18
  } else {
19
19
  next();