-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* π Refactor responseDto.ts * π Refactor `/request` dto * π Refactor `/request` `/response` dto * π Refactor response.http-response.dto.ts * π Refactor `/user` dto * π Remove /user/create description * π¨ Remove /user/create header * π Add HTTP Exception description
- Loading branch information
Showing
24 changed files
with
601 additions
and
946 deletions.
There are no files selected for viewing
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,125 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class HttpResponseDto { | ||
statusCode?: number; | ||
message: string; | ||
error: boolean; | ||
data?: object; | ||
|
||
constructor( | ||
statusCode: number, | ||
message: string, | ||
error: boolean, | ||
data?: object, | ||
) { | ||
this.statusCode = statusCode; | ||
this.message = message; | ||
this.error = error; | ||
this.data = data; | ||
} | ||
} | ||
|
||
export class BadRequestDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
example: 400, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
example: 'Bad Request', | ||
}) | ||
message: string; | ||
|
||
@ApiProperty({ | ||
example: true, | ||
}) | ||
error: boolean; | ||
|
||
constructor(message: string) { | ||
super(400, message, true); | ||
} | ||
} | ||
|
||
export class UnauthorizedDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
example: 401, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
example: 'Unauthorized', | ||
}) | ||
message: string; | ||
|
||
@ApiProperty({ | ||
example: true, | ||
}) | ||
error: boolean; | ||
|
||
constructor(message: string) { | ||
super(401, message, true); | ||
} | ||
} | ||
|
||
export class ForbiddenDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
example: 403, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
example: 'Forbidden', | ||
}) | ||
message: string; | ||
|
||
@ApiProperty({ | ||
example: true, | ||
}) | ||
error: boolean; | ||
|
||
constructor(message: string) { | ||
super(403, message, true); | ||
} | ||
} | ||
|
||
export class NotFoundDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
example: 404, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
example: 'Not Found', | ||
}) | ||
message: string; | ||
|
||
@ApiProperty({ | ||
example: true, | ||
}) | ||
error: boolean; | ||
|
||
constructor(message: string) { | ||
super(404, message, true); | ||
} | ||
} | ||
|
||
export class ConflictDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
example: 409, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
example: 'Conflict', | ||
}) | ||
message: string; | ||
|
||
@ApiProperty({ | ||
example: true, | ||
}) | ||
error: boolean; | ||
|
||
constructor(message: string) { | ||
super(409, message, true); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { HttpResponseDto } from '../../HttpResponseDto'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { RequestSchema } from '../entities/request.schema'; | ||
|
||
export class Created_CreateRequestDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
default: 200, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
default: 'κ³ΌμΈ μμ²μ΄ μ±κ³΅μ μΌλ‘ μμ±λμμ΅λλ€.', | ||
}) | ||
message: string; | ||
|
||
@ApiProperty({ | ||
default: false, | ||
}) | ||
error: boolean; | ||
|
||
constructor() { | ||
super(200, 'κ³ΌμΈ μμ²μ΄ μ±κ³΅μ μΌλ‘ μμ±λμμ΅λλ€.', false); | ||
} | ||
} | ||
|
||
export class Success_GetRequestsDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
default: 200, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
default: 'κ³ΌμΈ μμ² λͺ©λ‘μ μ±κ³΅μ μΌλ‘ κ°μ Έμμ΅λλ€.', | ||
}) | ||
@ApiProperty({ | ||
default: false, | ||
}) | ||
error: boolean; | ||
|
||
@ApiProperty({ | ||
type: RequestSchema, | ||
default: { | ||
requests: [ | ||
{ | ||
id: 'test-request-id', | ||
studentId: 'test-student-id', | ||
problem: { | ||
description: 'test-description', | ||
base64Image: 'test-base64-image', | ||
schoolLevel: 'test-school-level', | ||
schoolSubject: 'test-school-subject', | ||
schoolChapter: 'test-school-chapter', | ||
difficulty: 'test-difficulty', | ||
}, | ||
status: 'pending', | ||
tutoringId: null, | ||
createdAt: '2021-01-01T00:00:00.000Z', | ||
}, | ||
], | ||
}, | ||
}) | ||
data: typeof RequestSchema; | ||
|
||
constructor(data: object[]) { | ||
super(200, 'κ³ΌμΈ μμ² λͺ©λ‘μ μ±κ³΅μ μΌλ‘ κ°μ Έμμ΅λλ€.', false, data); | ||
} | ||
} | ||
|
||
export class Success_DeleteRequestDto extends HttpResponseDto { | ||
@ApiProperty({ | ||
default: 200, | ||
}) | ||
statusCode: number; | ||
|
||
@ApiProperty({ | ||
default: 'κ³ΌμΈ μμ²μ΄ μ±κ³΅μ μΌλ‘ μμ λμμ΅λλ€.', | ||
}) | ||
message: string; | ||
|
||
@ApiProperty({ | ||
default: false, | ||
}) | ||
error: boolean; | ||
|
||
constructor() { | ||
super(200, 'κ³ΌμΈ μμ²μ΄ μ±κ³΅μ μΌλ‘ μμ λμμ΅λλ€.', false); | ||
} | ||
} |
Oops, something went wrong.