Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move projects endpoint from ./data to ./api #557

Merged
merged 3 commits into from
Mar 26, 2023

Conversation

ZibanPirate
Copy link
Member

Description

added a new endpoint in ./api, that returns the projects listed under dzcode and display more info for each project such as contributors ...etc

you can test it by:

curl -X 'GET' \
  'http://localhost:7070/Projects/' \
  -H 'accept: text/html; charset=utf-8'

or by visiting:
http://localhost:7070/docs/#/Project/ProjectController.getProjects

Type of change

  • New feature (non-breaking change which adds functionality)

@ZibanPirate ZibanPirate self-assigned this Mar 26, 2023
@ZibanPirate ZibanPirate linked an issue Mar 26, 2023 that may be closed by this pull request
@ZibanPirate ZibanPirate added this to the migrate ./data to ./api milestone Mar 26, 2023
@github-actions github-actions bot added api API related changes ( api folder ) models models package labels Mar 26, 2023
@ZibanPirate ZibanPirate requested a review from a team March 26, 2023 11:49
Comment on lines +13 to +15
projects!: Array<
Model<ProjectEntity> & { repositories: Model<RepositoryEntity, "contributors" | "stats">[] }
>;
Copy link
Member

Choose a reason for hiding this comment

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

Could we use a type for this 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

the idea here (using Model generic) is to easily generate complex Models from related Entitys, instead of creating a type for each use-case.

as you can see, Model generic is limited for now to only allow you to define first-level child Entitys. I wrote a comment to expand it later, so we can go even deeper into second-level child Entitys, and we end up with something like this:

projects!: Model<ProjectEntity, 'repositories' | 'repositories.contributors' | 'repositories.stats'>[]

which will produce this complex interface:

interface GetProjectsResponseDto {
  ...,
  projects: Array<{
    slug: string;
    name: string;
    repositories: Array<{
      provider: "github" | "gitlab";
      owner: string;
      repository: string;
      stats: {
        contributionCount: number;
        languages: string[];
      };
      contributors: Array<{
        id: string;
        username: string;
        avatarUrl: string;
      }>;
    }>;
  }>;
}

Copy link
Member

Choose a reason for hiding this comment

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

I get it now, this is better actually

@ZibanPirate ZibanPirate merged commit 309d0c1 into main Mar 26, 2023
@ZibanPirate ZibanPirate deleted the 553-move-projects-endpoint-from-data-to-api branch March 26, 2023 21:30
@ZibanPirate ZibanPirate changed the title feat: move projects endpoint from ./data to ./api move projects endpoint from ./data to ./api Apr 15, 2023
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 ) models models package
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

move /Projects endpoint from ./data to ./api
2 participants