Skip to content

Conversation

@well-balanced
Copy link
Contributor

@well-balanced well-balanced commented Apr 10, 2021

Description

Implements #286

  • Call v2/GithubUsers/{username} from the frontend
  • Remove the old API /github/users

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

@github-actions github-actions bot added api API related changes ( api folder ) web Web related changes ( web folder ) labels Apr 10, 2021
@well-balanced well-balanced mentioned this pull request Apr 10, 2021
2 tasks
Copy link
Member

@ZibanPirate ZibanPirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a well written PR, couple more changes suggested, and we good to go 👌🏽

const githubUser = await this.githubService.getUser({
username,
});
const user = plainToClass(GithubUserDto, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to verify a service response, so the code from line 25 to 27 can be removed as well as on line 7

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yesss! I've just fixed it.
but can I ask a question? I added these lines for documentation. if I do not specify class object like a GithubUserDto into ResponseDto, I couldn't see any details in http://localhost:7070/v2/docs/ are there any issues when a user object is wrapped in a DTO object? It should be tiresome, but I would be learned lots of things from your reply :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, as i mentioned in the new comments, the nested objects inside the dto class has to be dto classes too, otherwise OpenApi will not pick them as specs in the docs, you also need to decorate them with @ValidateNested() (or @ValidateNested({ each: true }) and @Type(() => YouClassDto) for array of objects)

well-balanced and others added 2 commits April 11, 2021 02:59
Co-authored-by: Zakaria Mansouri <zakman.dev@gmail.com>
Copy link
Member

@ZibanPirate ZibanPirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last change and we're good to go!

well-balanced and others added 4 commits April 11, 2021 10:00
Co-authored-by: Zakaria Mansouri <zakman.dev@gmail.com>
Co-authored-by: Zakaria Mansouri <zakman.dev@gmail.com>
Co-authored-by: Zakaria Mansouri <zakman.dev@gmail.com>
Co-authored-by: Zakaria Mansouri <zakman.dev@gmail.com>
@well-balanced
Copy link
Contributor Author

Type 'GitHubUserApiResponse' is not assignable to type 'GithubUserDto'.
  Types of property 'id' are incompatible.
    Type 'number' is not assignable to type 'string'.

I think It's a conflict between GithubUserDto and GitHubUserApiResponse

export class GithubUserDto implements GithubUser {
  ...
  @IsString()
  id!: string;
  ...
}

export interface GitHubUserApiResponse {
  ...
  id: number;
  ...
}

Copy link
Member

@ZibanPirate ZibanPirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you're correct, we need to do 3 changes:

  1. in common/src/types/index.ts change line 43 to:
  id: number;
  1. in api/src/github/dto.ts change line 10 to:
  id!: number;
  1. in api/test/mocks.ts change lines 6, 14 and 22 to:
  id: 1,
  id: 2,
  id: 3,

@github-actions github-actions bot added the common Common related changes ( common folder ) label Apr 11, 2021
@well-balanced
Copy link
Contributor Author

@ZibanPirate I'm sorry to late 😭 I've just implemented earlier suggestion :)

Copy link
Member

@ZibanPirate ZibanPirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worries, thanks for your well balanced PR ;) merging ...

@ZibanPirate ZibanPirate merged commit db458cb into dzcode-io:main Apr 11, 2021
ZibanPirate added a commit that referenced this pull request Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api API related changes ( api folder ) common Common related changes ( common folder ) web Web related changes ( web folder )

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

2 participants