Skip to content

Commit 83729d8

Browse files
committed
refactor(exception): upgrade error and validate middleware
updated link in http client added entity decorator for otp changed otp.ts -> otp.entity.ts
1 parent 9c46c4d commit 83729d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+185
-125
lines changed

http/auth.http

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
### LOGIN [USER]
22
# @name loginUser
3-
POST {{apiUrl}}/v1/auth/login
3+
POST {{apiUrl}}/auth/login
44

55
{
66
"email": "{{$dotenv REST_USER_LOGIN}}",
77
"password": "{{$dotenv REST_USER_PASSWORD}}"
88
}
99

1010
### LOGOUT [USER]
11-
POST {{apiUrl}}/v1/auth/logout
12-
Authorization: Bearer {{loginUser.response.body.data.payload.accessToken}}
11+
POST {{apiUrl}}/auth/logout
12+
Authorization: Bearer {{loginUser.response.body.data.accessToken}}
1313

1414
### LOGOUT [USER]
15-
POST {{apiUrl}}/v1/auth/logout
16-
Cookie: accessToken={{loginUser.response.body.data.payload.accessToken}}
15+
POST {{apiUrl}}/auth/logout
16+
Cookie: accessToken={{loginUser.response.body.data.accessToken}}
1717

1818
### REFRESH-TOKEN [USER]
19-
POST {{apiUrl}}/v1/auth/refresh-token
19+
POST {{apiUrl}}/auth/refresh-token
2020

2121
{
22-
"refreshToken": "{{loginUser.response.body.data.payload.refreshToken}}"
22+
"refreshToken": "{{loginUser.response.body.data.refreshToken}}"
2323
}
2424

2525
### LOGS USER INTO THE SYSTEM THROUGH A APPLE
26-
POST {{apiUrl}}/v1/auth/platform
26+
POST {{apiUrl}}/auth/platform
2727

2828
{
2929
"token": "{{$dotenv REST_APPLE_TOKEN}}",
3030
"platform": "apple"
3131
}
3232

3333
### LOGS USER INTO THE SYSTEM THROUGH A FACEBOOK
34-
POST {{apiUrl}}/v1/auth/platform
34+
POST {{apiUrl}}/auth/platform
3535

3636
{
3737
"token": "{{$dotenv REST_FACEBOOK_TOKEN}}",
@@ -40,24 +40,33 @@ POST {{apiUrl}}/v1/auth/platform
4040

4141

4242
### LOGS USER INTO THE SYSTEM THROUGH A GOOGLE
43-
POST {{apiUrl}}/v1/auth/platform
43+
POST {{apiUrl}}/auth/platform
4444

4545
{
4646
"token": "{{$dotenv REST_GOOGLE_TOKEN}}",
4747
"platform": "github"
4848
}
4949

5050
### LOGS USER INTO THE SYSTEM THROUGH A GITHUB
51-
POST {{apiUrl}}/v1/auth/platform
51+
POST {{apiUrl}}/auth/platform
5252

5353
{
5454
"token": "{{$dotenv REST_GITHUB_TOKEN}}",
5555
"platform": "github"
5656
}
5757

5858
### FORGOT PASSWORD BY EMAIL
59-
POST {{apiUrl}}/v1/auth/password/email
59+
POST {{apiUrl}}/auth/password/email
60+
61+
{
62+
"email": "{{$dotenv REST_USER_LOGIN}}"
63+
}
64+
65+
### RESET PASSWORD BY EMAIL
66+
POST {{apiUrl}}/auth/password/reset/email
6067

6168
{
6269
"email": "{{$dotenv REST_USER_LOGIN}}",
70+
"token": "f5792b25-e9ce-44e4-a34d-a9382257b086",
71+
"password": "{{$dotenv REST_USER_PASSWORD}}"
6372
}

http/user.http

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
### RETURN A CURRENT USER [USER]
2-
GET {{apiUrl}}/v1/users/current
2+
GET {{apiUrl}}/users/current
33
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}
44

55
### CREATE A USER [USER]
6-
POST {{host}}/api/users
6+
POST {{apiUrl}}/users
77

88
{
99
"email": "{{$dotenv REST_USER_LOGIN}}",
@@ -15,7 +15,7 @@ POST {{host}}/api/users
1515
}
1616

1717
### UPDATE A CURRENT USER [USER]
18-
PUT {{apiUrl}}/v1/users/current
18+
PUT {{apiUrl}}/users/current
1919
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}
2020

2121
{
@@ -26,14 +26,14 @@ Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}
2626
}
2727

2828
### CHANGE PASSWORD FOR A CURRENT USER [USER]
29-
POST {{apiUrl}}/v1/users/current/change-password
29+
POST {{apiUrl}}/users/current/change-password
3030
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}
3131

3232
{
3333
"oldPassword": "{{$dotenv REST_USER_PASSWORD}}",
34-
"newPassword": "1234567"
34+
"newPassword": "87654321"
3535
}
3636

3737
### DELETE A CURRENT USER [USER]
38-
DELETE {{apiUrl}}/v1/users/current
38+
DELETE {{apiUrl}}/users/current
3939
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}

src/common/enums/exception.enum.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export enum HttpStatus {
22
OK = 200,
3-
Created = 201,
4-
NoContent = 204,
5-
BadRequest = 400,
6-
Unauthorized = 401,
7-
Forbidden = 403,
8-
NotFound = 404,
9-
Conflict = 409,
10-
UnprocessableEntity = 422,
11-
InternalServerError = 500,
3+
CREATED = 201,
4+
NO_CONTENT = 204,
5+
BAD_REQUEST = 400,
6+
UNAUTHORIZED = 401,
7+
FORBIDDEN = 403,
8+
NOT_FOUND = 404,
9+
CONFLICT = 409,
10+
UNPROCESSABLE_ENTITY = 422,
11+
INTERNAL_SERVER_ERROR = 500,
1212
}
1313

1414
export enum MessageCode {

src/common/exceptions/bad-request.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class BadRequestException extends HttpException {
99
super({
1010
message: message || i18n()['exception.badRequest'],
1111
messageCode: MessageCode.BAD_REQUEST,
12-
statusCode: HttpStatus.BadRequest,
12+
statusCode: HttpStatus.BAD_REQUEST,
1313
});
1414
}
1515
}

src/common/exceptions/conflict.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class ConflictException extends HttpException {
99
super({
1010
message: message || i18n()['exception.conflict'],
1111
messageCode: MessageCode.FORBIDDEN,
12-
statusCode: HttpStatus.Forbidden,
12+
statusCode: HttpStatus.FORBIDDEN,
1313
});
1414
}
1515
}

src/common/exceptions/forbidden.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class ForbiddenException extends HttpException {
99
super({
1010
message: message || i18n()['exception.forbidden'],
1111
messageCode: MessageCode.FORBIDDEN,
12-
statusCode: HttpStatus.Forbidden,
12+
statusCode: HttpStatus.FORBIDDEN,
1313
});
1414
}
1515
}

src/common/exceptions/http.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export class HttpException extends Error {
1313

1414
this.message = param?.message || i18n()['exception.serverError'];
1515
this.messageCode = param?.messageCode || MessageCode.INTERNAL_SERVER_ERROR;
16-
this.statusCode = param?.statusCode || HttpStatus.InternalServerError;
16+
this.statusCode = param?.statusCode || HttpStatus.INTERNAL_SERVER_ERROR;
1717
}
1818
}

src/common/exceptions/internal-server-error.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class InternalServerErrorException extends HttpException {
99
super({
1010
message: message || i18n()['exception.serverError'],
1111
messageCode: MessageCode.INTERNAL_SERVER_ERROR,
12-
statusCode: HttpStatus.InternalServerError,
12+
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
1313
});
1414
}
1515
}

src/common/exceptions/not-found.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class NotFoundException extends HttpException {
99
super({
1010
message: message || i18n()['exception.notFound'],
1111
messageCode: MessageCode.NOT_FOUND,
12-
statusCode: HttpStatus.NotFound,
12+
statusCode: HttpStatus.NOT_FOUND,
1313
});
1414
}
1515
}

src/common/exceptions/refresh-token-expired.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class RefreshTokenExpiredException extends HttpException {
88
super({
99
message: i18n()['exception.refreshTokenExpired'],
1010
messageCode: MessageCode.REFRESH_TOKEN_EXPIRED,
11-
statusCode: HttpStatus.Unauthorized,
11+
statusCode: HttpStatus.UNAUTHORIZED,
1212
});
1313
}
1414
}

0 commit comments

Comments
 (0)