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

Add recommended versions endpoint #17

Closed
wants to merge 1 commit into from
Closed

Add recommended versions endpoint #17

wants to merge 1 commit into from

Conversation

Jamalam360
Copy link

This PR adds an endpoint to fetch the data that is normally available at https://fabricmc.net/versions.html through the API. It is marked as a draft as it needs some discussion - I'll self review it to add some comments on things that need addressing. It would be ideal if #10 was merged so that it could also provide FAPI?

@Jamalam360 Jamalam360 marked this pull request as ready for review November 14, 2021 08:41
@@ -34,145 +34,170 @@
@SuppressWarnings("Duplicates")
public class EndpointsV2 {

public static void setup() {
public static void setup() {
Copy link
Author

Choose a reason for hiding this comment

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

Sorry about this diff, I must have pressed Ctrl Alt L in Idea and auto formatted everything


for(MavenBuildVersion loader : FabricMeta.database.getLoader()){
infoList.add(new LoaderInfoV2(loader, mappings).populateMeta());
private static Object getRecommendedVersions(Context context) {
Copy link
Author

Choose a reason for hiding this comment

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

This is the relevant part

}

return versions;
}
return new RecommendedVersions(gameVersion, yarn.get(0), loader.get(0));
Copy link
Author

Choose a reason for hiding this comment

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

It relies on the fact that the latest versions of yarn and loader are always first in the JSON - is this reliable?

WebServer.jsonGet("/v2/versions/loader", context -> withLimitSkip(context, FabricMeta.database.getLoader()));
WebServer.jsonGet("/v2/versions/loader/:game_version", context -> withLimitSkip(context, EndpointsV2.getLoaderInfoAll(context)));
WebServer.jsonGet("/v2/versions/loader/:game_version/:loader_version", EndpointsV2::getLoaderInfo);
WebServer.jsonGet("/v2/versions/:game_version", context -> EndpointsV2.getRecommendedVersions(context));
Copy link
Author

Choose a reason for hiding this comment

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

It could perhaps do with a better endpoint name

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant