Skip to content

Commit e06ef13

Browse files
resolve conflict
2 parents 01195a2 + 114435b commit e06ef13

File tree

5 files changed

+196
-201
lines changed

5 files changed

+196
-201
lines changed

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ack-nestjs-boilerplate-kafka",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"description": "Ack NestJs Boilerplate Kafka",
55
"repository": {
66
"type": "git",
@@ -47,7 +47,7 @@
4747
"rollback": "yarn rollback:setting && yarn rollback:apikey"
4848
},
4949
"dependencies": {
50-
"@aws-sdk/client-s3": "^3.241.0",
50+
"@aws-sdk/client-s3": "^3.245.0",
5151
"@faker-js/faker": "^7.6.0",
5252
"@joi/date": "^2.1.0",
5353
"@nestjs/axios": "^1.0.1",
@@ -73,11 +73,11 @@
7373
"joi": "^17.7.0",
7474
"kafkajs": "^2.2.3",
7575
"moment": "^2.29.4",
76-
"mongoose": "^6.8.2",
76+
"mongoose": "^6.8.3",
7777
"morgan": "^1.10.0",
7878
"nest-winston": "^1.8.0",
79-
"nestjs-command": "^3.1.2",
80-
"nestjs-i18n": "^10.2.3",
79+
"nestjs-command": "^3.1.3",
80+
"nestjs-i18n": "^10.2.4",
8181
"passport": "^0.6.0",
8282
"passport-headerapikey": "^1.2.2",
8383
"passport-jwt": "^4.0.1",
@@ -114,21 +114,21 @@
114114
"@types/supertest": "^2.0.12",
115115
"@types/ua-parser-js": "^0.7.36",
116116
"@types/uuid": "^9.0.0",
117-
"@typescript-eslint/eslint-plugin": "^5.47.1",
118-
"@typescript-eslint/parser": "^5.47.1",
117+
"@typescript-eslint/eslint-plugin": "^5.48.0",
118+
"@typescript-eslint/parser": "^5.48.0",
119119
"cspell": "^6.18.1",
120120
"eslint": "^8.31.0",
121-
"eslint-config-prettier": "^8.5.0",
121+
"eslint-config-prettier": "^8.6.0",
122122
"eslint-plugin-import": "^2.26.0",
123-
"husky": "^8.0.2",
123+
"husky": "^8.0.3",
124124
"jest": "^29.3.1",
125-
"prettier": "^2.8.1",
125+
"prettier": "^2.8.2",
126126
"supertest": "^6.3.3",
127127
"ts-jest": "^29.0.3",
128128
"ts-loader": "^9.4.2",
129129
"ts-node": "^10.9.1",
130130
"ts-prune": "^0.10.3",
131-
"tsconfig-paths": "^4.1.1",
131+
"tsconfig-paths": "^4.1.2",
132132
"typescript": "^4.9.4"
133133
}
134134
}

src/common/api-key/constants/api-key.status-code.constant.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ export enum ENUM_API_KEY_STATUS_CODE_ERROR {
55
API_KEY_EXPIRED_ERROR = 5123,
66
API_KEY_INACTIVE_ERROR = 5124,
77
API_KEY_INVALID_ERROR = 5125,
8-
API_KEY_PREFIX_INVALID_ERROR = 5126,
9-
API_KEY_WRONG_ERROR = 5127,
8+
API_KEY_WRONG_ERROR = 5126,
109
}

src/common/api-key/guards/x-api-key/api-key.x-api-key.guard.ts

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,67 +25,59 @@ export class ApiKeyXApiKeyGuard extends AuthGuard('api-key') {
2525
): IApiKeyPayload {
2626
if (err || !apiKey) {
2727
if (
28-
info instanceof Error &&
29-
info.name === 'BadRequestError' &&
30-
info.message === 'Missing API Key'
28+
(info instanceof Error &&
29+
info.name === 'BadRequestError' &&
30+
info.message === 'Missing API Key') ||
31+
!apiKey
3132
) {
3233
throw new UnauthorizedException({
3334
statusCode:
3435
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_NEEDED_ERROR,
3536
message: 'apiKey.error.keyNeeded',
3637
});
37-
} else if (
38-
info instanceof Error &&
39-
info.name === 'BadRequestError' &&
40-
info.message.startsWith('Invalid API Key prefix')
41-
) {
42-
throw new ForbiddenException({
43-
statusCode:
44-
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_PREFIX_INVALID_ERROR,
45-
message: 'apiKey.error.prefixInvalid',
46-
});
47-
}
38+
} else if (err) {
39+
const statusCode: number = this.helperNumberService.create(
40+
err.message as string
41+
);
4842

49-
const statusCode: number = this.helperNumberService.create(
50-
err.message as string
51-
);
52-
53-
if (
54-
statusCode ===
55-
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_NOT_FOUND_ERROR
56-
) {
57-
throw new ForbiddenException({
58-
statusCode,
59-
message: 'apiKey.error.notFound',
60-
});
61-
} else if (
62-
statusCode ===
63-
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_IS_ACTIVE_ERROR
64-
) {
65-
throw new ForbiddenException({
66-
statusCode,
67-
message: 'apiKey.error.inactive',
68-
});
69-
} else if (
70-
statusCode ===
71-
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_EXPIRED_ERROR
72-
) {
73-
throw new ForbiddenException({
74-
statusCode,
75-
message: 'apiKey.error.expired',
76-
});
77-
} else if (
78-
statusCode ===
79-
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_WRONG_ERROR
80-
) {
81-
throw new ForbiddenException({
82-
statusCode,
83-
message: 'apiKey.error.wrong',
84-
});
43+
if (
44+
statusCode ===
45+
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_NOT_FOUND_ERROR
46+
) {
47+
throw new ForbiddenException({
48+
statusCode,
49+
message: 'apiKey.error.notFound',
50+
});
51+
} else if (
52+
statusCode ===
53+
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_IS_ACTIVE_ERROR
54+
) {
55+
throw new ForbiddenException({
56+
statusCode,
57+
message: 'apiKey.error.inactive',
58+
});
59+
} else if (
60+
statusCode ===
61+
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_EXPIRED_ERROR
62+
) {
63+
throw new ForbiddenException({
64+
statusCode,
65+
message: 'apiKey.error.expired',
66+
});
67+
} else if (
68+
statusCode ===
69+
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_WRONG_ERROR
70+
) {
71+
throw new ForbiddenException({
72+
statusCode,
73+
message: 'apiKey.error.wrong',
74+
});
75+
}
8576
}
8677

8778
throw new UnauthorizedException({
88-
statusCode,
79+
statusCode:
80+
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_INVALID_ERROR,
8981
message: 'apiKey.error.invalid',
9082
});
9183
}

src/common/doc/decorators/doc.decorator.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ export function Doc<T>(
136136
statusCode: ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_NEEDED_ERROR,
137137
messagePath: 'apiKey.error.keyNeeded',
138138
},
139-
{
140-
statusCode:
141-
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_PREFIX_INVALID_ERROR,
142-
messagePath: 'apiKey.error.prefixInvalid',
143-
},
144139
{
145140
statusCode:
146141
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_NOT_FOUND_ERROR,
@@ -302,11 +297,6 @@ export function DocPaging<T>(
302297
statusCode: ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_NEEDED_ERROR,
303298
messagePath: 'apiKey.error.keyNeeded',
304299
},
305-
{
306-
statusCode:
307-
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_PREFIX_INVALID_ERROR,
308-
messagePath: 'apiKey.error.prefixInvalid',
309-
},
310300
{
311301
statusCode:
312302
ENUM_API_KEY_STATUS_CODE_ERROR.API_KEY_NOT_FOUND_ERROR,

0 commit comments

Comments
 (0)