-
Notifications
You must be signed in to change notification settings - Fork 43
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
move projects endpoint from ./data
to ./api
#557
Conversation
projects!: Array< | ||
Model<ProjectEntity> & { repositories: Model<RepositoryEntity, "contributors" | "stats">[] } | ||
>; |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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 Entity
s, 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 Entity
s. I wrote a comment to expand it later, so we can go even deeper into second-level child Entity
s, 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;
}>;
}>;
}>;
}
There was a problem hiding this comment.
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
./data
to ./api
./data
to ./api
Description
added a new endpoint in
./api
, that returns the projects listed under dzcode and display more info for each project such as contributors ...etcyou can test it by:
or by visiting:
http://localhost:7070/docs/#/Project/ProjectController.getProjects
Type of change