-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
πfeat(user) : μ 체 μ μ μ‘°ν νμ΄μ§λ€μ΄μ
ꡬν, μ μ λ³ ν°μΌμ νμΈ, ν°μΌμ ν¬ν¨ μ μ μλ΅ dto μμ± #57
- Loading branch information
Showing
103 changed files
with
4,058 additions
and
582 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
BadRequestException, | ||
Controller, | ||
ForbiddenException, | ||
Get, | ||
HttpStatus, | ||
UnauthorizedException | ||
} from '@nestjs/common'; | ||
import { ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { ThrottlerException } from '@nestjs/throttler'; | ||
import { AuthErrorDefine } from './auth/Errors/AuthErrorDefine'; | ||
|
||
import { ErrorResponse } from './common/decorators/ErrorResponse.decorator'; | ||
import { CustomValidationError } from './common/errors/ValidtionError'; | ||
@Controller() | ||
@ApiTags('common') | ||
export class CommonController { | ||
@ErrorResponse(HttpStatus.BAD_REQUEST, [ | ||
{ | ||
model: BadRequestException, | ||
exampleDescription: '400λ² BadRequestException', | ||
exampleTitle: '400 λ²μ BadRequestException', | ||
message: 'μλ¬λ©μμ§ νμμ΄ μ΅λλ€.' | ||
}, | ||
{ | ||
model: CustomValidationError, | ||
exampleDescription: '400λ² ValidationError', | ||
exampleTitle: '400λ² ValidationError', | ||
message: { | ||
'κ²μ¦μ€λ₯κ°λ νλ': ['μ΄λ€μλ¬', 'μ΄λ€μλ¬2'], | ||
'κ²μ¦μ€λ₯κ°λ νλ2': ['μ΄λ€μλ¬3', 'μ΄λ€μλ¬4'] | ||
} | ||
} | ||
]) | ||
@ErrorResponse(HttpStatus.UNAUTHORIZED, [ | ||
AuthErrorDefine['Auth-1000'], | ||
AuthErrorDefine['Auth-1001'], | ||
AuthErrorDefine['Auth-1002'], | ||
AuthErrorDefine['Auth-1003'] | ||
]) | ||
@ErrorResponse(HttpStatus.FORBIDDEN, [AuthErrorDefine['Auth-3000']]) | ||
@ErrorResponse(HttpStatus.TOO_MANY_REQUESTS, [AuthErrorDefine['Auth-9000']]) | ||
@ApiOperation({ summary: 'κ³΅ν΅ μ€λ₯μ λν΄μ μ μ ν©λλ€.' }) | ||
@Get() | ||
commen() {} | ||
} | ||
// { | ||
// κ²μ¦μ€λ₯: { | ||
// value: makeInstanceByApiProperty( | ||
// ErrorCommonResponse<ValidationErrorResponseDto>, | ||
// ValidationErrorResponseDto | ||
// ), | ||
// description: | ||
// '리ν΄λ registerTokenμ Bearer <registerToken> νμμΌλ‘ μ§μ΄λ£μΌμλ©΄λ©λλ€.' | ||
// }, | ||
// 'http μ€λ₯': { | ||
// value: makeInstanceByApiProperty( | ||
// ErrorCommonResponse<HttpExceptionErrorResponseDto>, | ||
// HttpExceptionErrorResponseDto | ||
// ), | ||
// description: | ||
// '리ν΄λ registerTokenμ Bearer <registerToken> νμμΌλ‘ μ§μ΄λ£μΌμλ©΄λ©λλ€.' | ||
// } | ||
// // 'μ΄λ―Έ νμκ°μ ν μ μ μΌλ': { | ||
// // value: makeInstanceByApiProperty(LoginResponseDto) | ||
// // } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import { | ||
BadRequestException, | ||
ForbiddenException, | ||
InternalServerErrorException, | ||
UnauthorizedException | ||
} from '@nestjs/common'; | ||
import { ThrottlerException } from '@nestjs/throttler'; | ||
import { ErrorResponseOption } from 'src/common/decorators/ErrorResponse.decorator'; | ||
type Keys = | ||
| 'Auth-1000' | ||
| 'Auth-1001' | ||
| 'Auth-1002' | ||
| 'Auth-1003' | ||
| 'Auth-3000' | ||
| 'Auth-9000' | ||
| 'Auth-5000' | ||
| 'Auth-0000' | ||
| 'Auth-0001' | ||
| 'Auth-0002' | ||
| 'Auth-0003' | ||
| 'Auth-0004' | ||
| 'Auth-0005'; | ||
|
||
export const AuthErrorDefine: Record< | ||
Keys, | ||
ErrorResponseOption & { code: string } | ||
> = { | ||
//400 | ||
'Auth-0000': { | ||
model: BadRequestException, | ||
exampleDescription: '3λΆμ§λ¦¬ μΈμ¦λ²νΈ κΈ°νλ§λ£μμ λ°μνλ μ€λ₯', | ||
exampleTitle: 'μΈμ¦λ²νΈ-κΈ°νλ§λ£', | ||
message: 'μΈμ¦λ²νΈκ° κΈ°νλ§λ£ λμμ΅λλ€.', | ||
code: 'Auth-0000' | ||
}, | ||
'Auth-0001': { | ||
model: BadRequestException, | ||
exampleDescription: 'μΈμ¦λ²νΈκ° μΌμΉνμ§ μμΌλ©΄ λ°μνλ μ€λ₯', | ||
exampleTitle: 'μΈμ¦λ²νΈ-λΆμΌμΉ', | ||
message: 'μΈμ¦λ²νΈκ° μΌμΉνμ§ μμ΅λλ€.', | ||
code: 'Auth-0001' | ||
}, | ||
'Auth-0002': { | ||
model: BadRequestException, | ||
exampleDescription: 'μ€λ³΅ν΄μ νμκ°μ μ μλνλ©΄ λ§μ΅λλ€.', | ||
exampleTitle: 'μ€λ³΅νμκ°μ μμ²', | ||
message: 'μ΄λ―Έ νμκ°μ ν μ μ μ λλ€.', | ||
code: 'Auth-0002' | ||
}, | ||
|
||
'Auth-0003': { | ||
model: BadRequestException, | ||
exampleDescription: 'μ¬λμ λ±λ‘λμ§μμ μ μ μΌλ λ°μνλ μ€λ₯', | ||
exampleTitle: 'μ 보μ€λ₯-μ μ μ 보,μ¬λμ 보μμ', | ||
message: 'κ°μ ν μ μ λ μ΄λλ―Ό μ μ κ° μλλλ€.', | ||
code: 'Auth-0003' | ||
}, | ||
'Auth-0004': { | ||
model: BadRequestException, | ||
exampleDescription: 'λ°μ μ¬λμ΄λ©μΌμ΄ μ¬λ°λ₯΄μ§μμκ²½μ°', | ||
exampleTitle: 'μ 보μ€λ₯-μ¬λμ 보μμ', | ||
message: 'κ°μ ν μ¬λ μ΄λ©μΌμ μ¬λ°λ₯΄κ² μ λ ₯ν΄ μ£ΌμΈμ', | ||
code: 'Auth-0004' | ||
}, | ||
|
||
'Auth-0005': { | ||
model: BadRequestException, | ||
exampleDescription: 'κ°μ ν μ μ λ μ΄λλ―Ό μ μ κ° μλλ', | ||
exampleTitle: 'μΈμ¦λ²νΈ-κ²μ¦μ΄ν', | ||
message: 'κ°μ ν μ μ λ μ΄λλ―Ό μ μ κ° μλλλ€.', | ||
code: 'Auth-0005' | ||
}, | ||
|
||
//401 | ||
'Auth-1000': { | ||
model: UnauthorizedException, | ||
exampleDescription: 'ν€λ Bearer νμμ μ§ν€μ§ μκ³ μλͺ» μμ² λ³΄λμ λ', | ||
exampleTitle: 'μ΄μΈμ€ν ν°-μλͺ»λ ν€λ μμ²', | ||
message: 'μλͺ»λ ν€λ μμ²', | ||
code: 'Auth-1000' | ||
}, | ||
|
||
'Auth-1001': { | ||
model: UnauthorizedException, | ||
exampleDescription: | ||
'μμλκ±°λ Bearer νμμ λ§μ·λλ° ν ν°μ΄ μ΄μν ν ν°μΌ λ', | ||
exampleTitle: 'μ΄μΈμ€ν ν°-μλͺ»λ ν ν°', | ||
message: 'μλͺ»λ ν ν°', | ||
code: 'Auth-1001' | ||
}, | ||
|
||
'Auth-1002': { | ||
model: UnauthorizedException, | ||
exampleDescription: 'κΈ°νμ΄ μ§λ ν ν°μΌλ', | ||
exampleTitle: 'μ΄μΈμ€ν ν°-κΈ°νλ§λ£', | ||
message: 'κΈ°νλ§λ£', | ||
code: 'Auth-1002' | ||
}, | ||
'Auth-1003': { | ||
model: UnauthorizedException, | ||
exampleDescription: | ||
'μ΄μΈμ€ν ν°μ μ΄μμμ§λ§ dbμμ μ μ κ° μμ λμμλ (ν μ€νΈν λ λ°μν μμλ μ€λ₯)', | ||
exampleTitle: 'μ΄μΈμ€ν ν°-μ μ μμ', | ||
message: 'μλ μ μ μ λλ€.', | ||
code: 'Auth-1003' | ||
}, | ||
|
||
//403 | ||
'Auth-3000': { | ||
model: ForbiddenException, | ||
exampleDescription: 'μΌλ° μ μ κ° κ΄λ¦¬μμ λ©μλμ μ κ·Ό νλ €κ³ ν λ', | ||
exampleTitle: 'κ΄λ¦¬μλ©μλμ μ μ κ° μ κ·Ό', | ||
message: 'κΆνμ΄ μμ΅λλ€.', | ||
code: 'Auth-3000' | ||
}, | ||
|
||
//500 | ||
'Auth-5000': { | ||
model: InternalServerErrorException, | ||
exampleDescription: 'λ¬Έμλ©μμ§ λ°μ‘μ΄ μ€ν¨νλ©΄ λ°μν©λλ€.', | ||
exampleTitle: 'λ¬Έμλ©μμ§ λ°μ‘μ€ν¨ μ€λ₯', | ||
message: | ||
'λ¬Έμλ©μμ§ λ°μ‘ μ€ν¨. κ³ μ€λ½ μΉ΄μΉ΄μ€ν‘ μ±λμ νμ©ν΄μ κ΄λ¦¬μνν μ°λ½ λΆνλ립λλ€.', | ||
code: 'Auth-5000' | ||
}, | ||
|
||
// μ€λ‘ν | ||
'Auth-9000': { | ||
model: ThrottlerException, | ||
exampleDescription: | ||
'κ³Όλν μμ²μ 보λΌμμ ( μΈμ¦λ¬Έμ μμ² , κ΄λ¦¬μ μ¬λ μΈμ¦ μμ²', | ||
exampleTitle: 'κ³Όλν μμ²', | ||
message: 'ThrottlerException: Too Many Requests', | ||
code: 'Auth-9000' | ||
} | ||
}; |
Oops, something went wrong.